@ni/nimble-components 20.15.0 → 20.15.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/dist/all-components-bundle.js +12405 -11698
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +2923 -2830
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/rich-text/base/index.d.ts +36 -0
- package/dist/esm/rich-text/base/index.js +73 -0
- package/dist/esm/rich-text/base/index.js.map +1 -0
- package/dist/esm/rich-text/editor/index.d.ts +25 -27
- package/dist/esm/rich-text/editor/index.js +95 -173
- package/dist/esm/rich-text/editor/index.js.map +1 -1
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.d.ts +3 -0
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js +228 -0
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js.map +1 -0
- package/dist/esm/rich-text/editor/styles.js +9 -1
- package/dist/esm/rich-text/editor/styles.js.map +1 -1
- package/dist/esm/rich-text/editor/template.js +2 -2
- package/dist/esm/rich-text/editor/template.js.map +1 -1
- package/dist/esm/rich-text/editor/testing/rich-text-editor.pageobject.d.ts +4 -0
- package/dist/esm/rich-text/editor/testing/rich-text-editor.pageobject.js +24 -4
- package/dist/esm/rich-text/editor/testing/rich-text-editor.pageobject.js.map +1 -1
- package/dist/esm/rich-text/editor/testing/types.d.ts +15 -0
- package/dist/esm/rich-text/editor/testing/types.js.map +1 -1
- package/dist/esm/rich-text/editor/types.d.ts +1 -0
- package/dist/esm/rich-text/editor/types.js +1 -0
- package/dist/esm/rich-text/editor/types.js.map +1 -1
- package/dist/esm/rich-text/models/configuration.d.ts +10 -0
- package/dist/esm/rich-text/models/configuration.js +15 -0
- package/dist/esm/rich-text/models/configuration.js.map +1 -0
- package/dist/esm/rich-text/models/editor-configuration.d.ts +10 -0
- package/dist/esm/rich-text/models/editor-configuration.js +14 -0
- package/dist/esm/rich-text/models/editor-configuration.js.map +1 -0
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.d.ts +2 -2
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.js +5 -1
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.js.map +1 -1
- package/dist/esm/rich-text/models/markdown-parser.d.ts +8 -1
- package/dist/esm/rich-text/models/markdown-parser.js +20 -4
- package/dist/esm/rich-text/models/markdown-parser.js.map +1 -1
- package/dist/esm/rich-text/models/markdown-serializer.d.ts +4 -3
- package/dist/esm/rich-text/models/markdown-serializer.js +16 -5
- package/dist/esm/rich-text/models/markdown-serializer.js.map +1 -1
- package/dist/esm/rich-text/models/mention-extension-configuration.d.ts +15 -0
- package/dist/esm/rich-text/models/mention-extension-configuration.js +18 -0
- package/dist/esm/rich-text/models/mention-extension-configuration.js.map +1 -0
- package/dist/esm/rich-text/viewer/index.d.ts +5 -23
- package/dist/esm/rich-text/viewer/index.js +13 -61
- package/dist/esm/rich-text/viewer/index.js.map +1 -1
- package/dist/esm/rich-text/viewer/styles.js +2 -1
- package/dist/esm/rich-text/viewer/styles.js.map +1 -1
- package/dist/esm/rich-text-mention/base/index.d.ts +17 -16
- package/dist/esm/rich-text-mention/base/index.js +34 -20
- package/dist/esm/rich-text-mention/base/index.js.map +1 -1
- package/dist/esm/rich-text-mention/base/models/mention-internals.d.ts +9 -4
- package/dist/esm/rich-text-mention/base/models/mention-internals.js +6 -2
- package/dist/esm/rich-text-mention/base/models/mention-internals.js.map +1 -1
- package/dist/esm/rich-text-mention/base/models/mention-validator.d.ts +3 -5
- package/dist/esm/rich-text-mention/base/models/mention-validator.js +6 -10
- package/dist/esm/rich-text-mention/base/models/mention-validator.js.map +1 -1
- package/dist/esm/rich-text-mention/base/template.d.ts +1 -1
- package/dist/esm/rich-text-mention/base/template.js +1 -1
- package/dist/esm/rich-text-mention/base/template.js.map +1 -1
- package/dist/esm/rich-text-mention/base/types.d.ts +10 -0
- package/dist/esm/rich-text-mention/base/types.js +2 -0
- package/dist/esm/rich-text-mention/base/types.js.map +1 -0
- package/dist/esm/rich-text-mention/users/index.d.ts +2 -3
- package/dist/esm/rich-text-mention/users/index.js +1 -6
- package/dist/esm/rich-text-mention/users/index.js.map +1 -1
- package/dist/esm/rich-text-mention/{base → users}/models/mapping-user-config.d.ts +1 -1
- package/dist/esm/rich-text-mention/{base → users}/models/mapping-user-config.js +1 -1
- package/dist/esm/rich-text-mention/users/models/mapping-user-config.js.map +1 -0
- package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.d.ts +4 -2
- package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.js +11 -2
- package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.js.map +1 -1
- package/dist/esm/rich-text-mention/users/view/styles.js +8 -3
- package/dist/esm/rich-text-mention/users/view/styles.js.map +1 -1
- package/package.json +3 -1
- package/dist/esm/rich-text-mention/base/models/mapping-user-config.js.map +0 -1
|
@@ -13,15 +13,21 @@ export class RichTextMarkdownParser {
|
|
|
13
13
|
*/
|
|
14
14
|
static parseMarkdownToDOM(value, markdownParserMentionConfig) {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
RichTextMarkdownParser.setup(markdownParserMentionConfig);
|
|
17
17
|
const parsedMarkdownContent = this.markdownParser.parse(value);
|
|
18
18
|
if (parsedMarkdownContent === null) {
|
|
19
|
-
return
|
|
19
|
+
return {
|
|
20
|
+
fragment: document.createDocumentFragment(),
|
|
21
|
+
mentionedHrefs: Array.from(RichTextMarkdownParser.mentionedHrefs)
|
|
22
|
+
};
|
|
20
23
|
}
|
|
21
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
fragment: this.domSerializer.serializeFragment(parsedMarkdownContent.content),
|
|
26
|
+
mentionedHrefs: Array.from(RichTextMarkdownParser.mentionedHrefs)
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
finally {
|
|
24
|
-
|
|
30
|
+
RichTextMarkdownParser.cleanup();
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
static initializeMarkdownParser() {
|
|
@@ -72,6 +78,7 @@ export class RichTextMarkdownParser {
|
|
|
72
78
|
const currentMention = RichTextMarkdownParser.mentionConfigs?.find(mention => mention.isValidMentionHref(href));
|
|
73
79
|
const displayName = currentMention?.getDisplayName(href);
|
|
74
80
|
if (currentMention && displayName) {
|
|
81
|
+
RichTextMarkdownParser.mentionedHrefs.add(href);
|
|
75
82
|
return [
|
|
76
83
|
currentMention.viewElement,
|
|
77
84
|
{
|
|
@@ -102,8 +109,17 @@ export class RichTextMarkdownParser {
|
|
|
102
109
|
}
|
|
103
110
|
});
|
|
104
111
|
}
|
|
112
|
+
static setup(markdownParserMentionConfig) {
|
|
113
|
+
RichTextMarkdownParser.mentionConfigs = markdownParserMentionConfig;
|
|
114
|
+
RichTextMarkdownParser.mentionedHrefs.clear();
|
|
115
|
+
}
|
|
116
|
+
static cleanup() {
|
|
117
|
+
RichTextMarkdownParser.mentionConfigs = undefined;
|
|
118
|
+
RichTextMarkdownParser.mentionedHrefs.clear();
|
|
119
|
+
}
|
|
105
120
|
}
|
|
106
121
|
_a = RichTextMarkdownParser;
|
|
122
|
+
RichTextMarkdownParser.mentionedHrefs = new Set();
|
|
107
123
|
RichTextMarkdownParser.updatedSchema = _a.getCustomSchemaConfiguration();
|
|
108
124
|
RichTextMarkdownParser.markdownParser = _a.initializeMarkdownParser();
|
|
109
125
|
RichTextMarkdownParser.domSerializer = DOMSerializer.fromSchema(_a.updatedSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-parser.js","sourceRoot":"","sources":["../../../../src/rich-text/models/markdown-parser.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,MAAM,EACN,qBAAqB,EACrB,cAAc,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file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AC,CAAC,CAAC,IAAI;gCAC9C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAW;6BAC9B;yBACJ,CAAC;oBACN,CAAC;iBACJ;gBACD,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE;gBAChC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAE;aAC3C;SACJ,CAAC,CAAC;IACP,CAAC;IAEO,MAAM,CAAC,KAAK,CAChB,2BAEW;QAEX,sBAAsB,CAAC,cAAc,GAAG,2BAA2B,CAAC;QACpE,sBAAsB,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,OAAO;QAClB,sBAAsB,CAAC,cAAc,GAAG,SAAS,CAAC;QAClD,sBAAsB,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;;;AAzJuB,qCAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;AACxC,oCAAa,GAAG,EAAI,CAAC,4BAA4B,EAAE,CAAC;AAEpD,qCAAc,GAAG,EAAI,CAAC,wBAAwB,EAAE,CAAC;AACjD,oCAAa,GAAG,aAAa,CAAC,UAAU,CAC5D,EAAI,CAAC,aAAa,CACrB,CAAC"}
|
|
@@ -3,7 +3,8 @@ import type { Node } from 'prosemirror-model';
|
|
|
3
3
|
* Provides markdown serializer for rich text components
|
|
4
4
|
*/
|
|
5
5
|
export declare class RichTextMarkdownSerializer {
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
private readonly markdownSerializer;
|
|
7
|
+
constructor(mentionList: string[]);
|
|
8
|
+
serializeDOMToMarkdown(doc: Node): string;
|
|
9
|
+
private initializeMarkdownSerializerForTipTap;
|
|
9
10
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import { MarkdownSerializer, defaultMarkdownSerializer } from 'prosemirror-markdown';
|
|
3
2
|
/**
|
|
4
3
|
* Provides markdown serializer for rich text components
|
|
5
4
|
*/
|
|
6
5
|
export class RichTextMarkdownSerializer {
|
|
7
|
-
|
|
6
|
+
constructor(mentionList) {
|
|
7
|
+
this.markdownSerializer = this.initializeMarkdownSerializerForTipTap(mentionList);
|
|
8
|
+
}
|
|
9
|
+
serializeDOMToMarkdown(doc) {
|
|
8
10
|
return this.markdownSerializer.serialize(doc);
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
initializeMarkdownSerializerForTipTap(mentionList) {
|
|
11
13
|
/**
|
|
12
14
|
* orderedList Node is getting 'order' attribute which it is not present in the
|
|
13
15
|
* tip-tap orderedList Node and having start instead of order, Changed it to start (nodes.attrs.start)
|
|
@@ -23,6 +25,14 @@ export class RichTextMarkdownSerializer {
|
|
|
23
25
|
return `${state.repeat(' ', maxW - nStr.length) + nStr}. `;
|
|
24
26
|
});
|
|
25
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Same as of auto link serialization https://github.com/ProseMirror/prosemirror-markdown/blob/3e5a5d02f7c1b9336744740149767ee1dc4e954d/src/to_markdown.ts#L136,
|
|
30
|
+
* href been extracted from the mention node and serialized it in between '<>' angular brackets.
|
|
31
|
+
*/
|
|
32
|
+
const mentionNode = function mention(state, node) {
|
|
33
|
+
const href = node.attrs.href;
|
|
34
|
+
state.write(`<${href}>`);
|
|
35
|
+
};
|
|
26
36
|
/**
|
|
27
37
|
* Internally Tiptap editor creates it own schema ( Nodes AND Marks ) based on the extensions ( Here Starter Kit is used for Bold, italic, orderedList and
|
|
28
38
|
* bulletList extensions) and defaultMarkdownSerializer uses schema from prosemirror-markdown to serialize the markdown.
|
|
@@ -38,6 +48,9 @@ export class RichTextMarkdownSerializer {
|
|
|
38
48
|
text: defaultMarkdownSerializer.nodes.text,
|
|
39
49
|
hardBreak: defaultMarkdownSerializer.nodes.hard_break
|
|
40
50
|
};
|
|
51
|
+
mentionList.forEach(item => {
|
|
52
|
+
nodes[item] = mentionNode;
|
|
53
|
+
});
|
|
41
54
|
const marks = {
|
|
42
55
|
italic: defaultMarkdownSerializer.marks.em,
|
|
43
56
|
bold: defaultMarkdownSerializer.marks.strong,
|
|
@@ -66,6 +79,4 @@ export class RichTextMarkdownSerializer {
|
|
|
66
79
|
return new MarkdownSerializer(nodes, marks);
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
|
-
_a = RichTextMarkdownSerializer;
|
|
70
|
-
RichTextMarkdownSerializer.markdownSerializer = _a.initializeMarkdownSerializerForTipTap();
|
|
71
82
|
//# sourceMappingURL=markdown-serializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-serializer.js","sourceRoot":"","sources":["../../../../src/rich-text/models/markdown-serializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-serializer.js","sourceRoot":"","sources":["../../../../src/rich-text/models/markdown-serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EAE5B,MAAM,sBAAsB,CAAC;AAY9B;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAGnC,YAAmB,WAAqB;QACpC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,qCAAqC,CAAC,WAAW,CAAC,CAAC;IACtF,CAAC;IAEM,sBAAsB,CAAC,GAAS;QACnC,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAEO,qCAAqC,CACzC,WAAqB;QAErB;;;;;WAKG;QACH,MAAM,eAAe,GAAG,SAAS,WAAW,CACxC,KAA8B,EAC9B,IAAU;YAEV,MAAM,KAAK,GAAI,IAAI,CAAC,KAAK,CAAC,KAAgB,IAAI,CAAC,CAAC;YAChD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;YACxD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM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I,EAAE;gBACF,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,GAAG;gBACV,MAAM,EAAE,KAAK;gBACb,wBAAwB,EAAE,IAAI;aACjC;SACJ,CAAC;QAEF,OAAO,IAAI,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MentionInternals } from '../../rich-text-mention/base/models/mention-internals';
|
|
2
|
+
import type { MentionUpdateEmitter } from '../../rich-text-mention/base/types';
|
|
3
|
+
/**
|
|
4
|
+
* A configuration object for a Mention extension, to be used by the editor for loading mention plugins in tiptap.
|
|
5
|
+
* This object maintains the necessary internal values for loading mention extension.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MentionExtensionConfiguration {
|
|
8
|
+
private static instance;
|
|
9
|
+
readonly viewElement: string;
|
|
10
|
+
readonly character: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly mentionUpdateEmitter: MentionUpdateEmitter;
|
|
14
|
+
constructor(mentionInternals: MentionInternals);
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mentionPluginPrefix } from '../editor/types';
|
|
2
|
+
/**
|
|
3
|
+
* A configuration object for a Mention extension, to be used by the editor for loading mention plugins in tiptap.
|
|
4
|
+
* This object maintains the necessary internal values for loading mention extension.
|
|
5
|
+
*/
|
|
6
|
+
export class MentionExtensionConfiguration {
|
|
7
|
+
constructor(mentionInternals) {
|
|
8
|
+
MentionExtensionConfiguration.instance += 1;
|
|
9
|
+
const key = `${mentionPluginPrefix}${MentionExtensionConfiguration.instance}`;
|
|
10
|
+
this.name = key;
|
|
11
|
+
this.key = key;
|
|
12
|
+
this.viewElement = mentionInternals.viewElement;
|
|
13
|
+
this.character = mentionInternals.character;
|
|
14
|
+
this.mentionUpdateEmitter = mentionInternals.mentionUpdateEmitter;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
MentionExtensionConfiguration.instance = 0;
|
|
18
|
+
//# sourceMappingURL=mention-extension-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-extension-configuration.js","sourceRoot":"","sources":["../../../../src/rich-text/models/mention-extension-configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IAStC,YAAmB,gBAAkC;QACjD,6BAA6B,CAAC,QAAQ,IAAI,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,GAAG,mBAAmB,GAAG,6BAA6B,CAAC,QAAQ,EAAE,CAAC;QAC9E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC;QAC5C,IAAI,CAAC,oBAAoB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC;IACtE,CAAC;;AAjBc,sCAAQ,GAAG,CAAC,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RichTextMention } from '../../rich-text-mention/base';
|
|
3
|
-
import { MarkdownParserMentionConfiguration } from '../models/markdown-parser-mention-configuration';
|
|
1
|
+
import { RichText } from '../base';
|
|
4
2
|
declare global {
|
|
5
3
|
interface HTMLElementTagNameMap {
|
|
6
4
|
'nimble-rich-text-viewer': RichTextViewer;
|
|
@@ -9,7 +7,7 @@ declare global {
|
|
|
9
7
|
/**
|
|
10
8
|
* A nimble styled rich text viewer
|
|
11
9
|
*/
|
|
12
|
-
export declare class RichTextViewer extends
|
|
10
|
+
export declare class RichTextViewer extends RichText {
|
|
13
11
|
/**
|
|
14
12
|
*
|
|
15
13
|
* @public
|
|
@@ -20,19 +18,7 @@ export declare class RichTextViewer extends FoundationElement {
|
|
|
20
18
|
* @internal
|
|
21
19
|
*/
|
|
22
20
|
viewer: HTMLDivElement;
|
|
23
|
-
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
mentionElements: RichTextMention[];
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
mentionInternalsConfig: MarkdownParserMentionConfiguration[];
|
|
31
|
-
/**
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
readonly childItems: Element[];
|
|
35
|
-
private mentionInternalsNotifiers;
|
|
21
|
+
private mentionedHrefs;
|
|
36
22
|
/**
|
|
37
23
|
* @internal
|
|
38
24
|
*/
|
|
@@ -44,12 +30,8 @@ export declare class RichTextViewer extends FoundationElement {
|
|
|
44
30
|
/**
|
|
45
31
|
* @internal
|
|
46
32
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private updateMentionsFromChildItems;
|
|
50
|
-
private observeMentions;
|
|
51
|
-
private removeMentionObservers;
|
|
52
|
-
private updateMentionInternalsConfig;
|
|
33
|
+
configurationChanged(): void;
|
|
34
|
+
getMentionedHrefs(): string[];
|
|
53
35
|
private updateView;
|
|
54
36
|
}
|
|
55
37
|
export declare const richTextViewerTag: string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { DesignSystem
|
|
3
|
-
import {
|
|
2
|
+
import { DesignSystem } from '@microsoft/fast-foundation';
|
|
3
|
+
import { observable } from '@microsoft/fast-element';
|
|
4
4
|
import { template } from './template';
|
|
5
5
|
import { styles } from './styles';
|
|
6
6
|
import { RichTextMarkdownParser } from '../models/markdown-parser';
|
|
7
|
-
import {
|
|
8
|
-
import { MentionInternals } from '../../rich-text-mention/base/models/mention-internals';
|
|
9
|
-
import { MarkdownParserMentionConfiguration } from '../models/markdown-parser-mention-configuration';
|
|
7
|
+
import { RichText } from '../base';
|
|
10
8
|
/**
|
|
11
9
|
* A nimble styled rich text viewer
|
|
12
10
|
*/
|
|
13
|
-
export class RichTextViewer extends
|
|
11
|
+
export class RichTextViewer extends RichText {
|
|
14
12
|
constructor() {
|
|
15
13
|
super(...arguments);
|
|
16
14
|
/**
|
|
@@ -19,19 +17,7 @@ export class RichTextViewer extends FoundationElement {
|
|
|
19
17
|
* Markdown string to render its corresponding rich text content in the component.
|
|
20
18
|
*/
|
|
21
19
|
this.markdown = '';
|
|
22
|
-
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
this.mentionElements = [];
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
this.mentionInternalsConfig = [];
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
this.childItems = [];
|
|
34
|
-
this.mentionInternalsNotifiers = [];
|
|
20
|
+
this.mentionedHrefs = [];
|
|
35
21
|
}
|
|
36
22
|
/**
|
|
37
23
|
* @internal
|
|
@@ -49,64 +35,30 @@ export class RichTextViewer extends FoundationElement {
|
|
|
49
35
|
/**
|
|
50
36
|
* @internal
|
|
51
37
|
*/
|
|
52
|
-
|
|
53
|
-
if (source instanceof MentionInternals && typeof args === 'string') {
|
|
54
|
-
this.updateMentionInternalsConfig();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
childItemsChanged() {
|
|
58
|
-
void this.updateMentionsFromChildItems();
|
|
59
|
-
}
|
|
60
|
-
async updateMentionsFromChildItems() {
|
|
61
|
-
const definedElements = this.childItems.map(async (item) => (item.matches(':not(:defined)')
|
|
62
|
-
? customElements.whenDefined(item.localName)
|
|
63
|
-
: Promise.resolve()));
|
|
64
|
-
await Promise.all(definedElements);
|
|
65
|
-
this.mentionElements = this.childItems.filter((x) => x instanceof RichTextMention);
|
|
66
|
-
this.observeMentions();
|
|
67
|
-
this.updateMentionInternalsConfig();
|
|
68
|
-
}
|
|
69
|
-
observeMentions() {
|
|
70
|
-
this.removeMentionObservers();
|
|
71
|
-
for (const mention of this.mentionElements) {
|
|
72
|
-
const notifierInternals = Observable.getNotifier(mention.mentionInternals);
|
|
73
|
-
notifierInternals.subscribe(this);
|
|
74
|
-
this.mentionInternalsNotifiers.push(notifierInternals);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
removeMentionObservers() {
|
|
78
|
-
this.mentionInternalsNotifiers.forEach(notifier => {
|
|
79
|
-
notifier.unsubscribe(this);
|
|
80
|
-
});
|
|
81
|
-
this.mentionInternalsNotifiers = [];
|
|
82
|
-
}
|
|
83
|
-
updateMentionInternalsConfig() {
|
|
84
|
-
// TODO: Add a rich text validator to check if the `mentionElements` contains duplicate configuration element
|
|
85
|
-
// For example, having two `nimble-rich-text-mention-users` within the children of rich text viewer or editor is an invalid configuration
|
|
86
|
-
this.mentionInternalsConfig = this.mentionElements
|
|
87
|
-
.filter(mention => mention.mentionInternals.validConfiguration)
|
|
88
|
-
.map(mention => new MarkdownParserMentionConfiguration(mention.mentionInternals));
|
|
38
|
+
configurationChanged() {
|
|
89
39
|
this.updateView();
|
|
90
40
|
}
|
|
41
|
+
getMentionedHrefs() {
|
|
42
|
+
return Array.from(this.mentionedHrefs);
|
|
43
|
+
}
|
|
91
44
|
updateView() {
|
|
92
45
|
if (!this.$fastController.isConnected) {
|
|
93
46
|
return;
|
|
94
47
|
}
|
|
95
48
|
if (this.markdown) {
|
|
96
|
-
const
|
|
97
|
-
this.viewer.replaceChildren(
|
|
49
|
+
const parseResult = RichTextMarkdownParser.parseMarkdownToDOM(this.markdown, this.configuration?.parserMentionConfig);
|
|
50
|
+
this.viewer.replaceChildren(parseResult.fragment);
|
|
51
|
+
this.mentionedHrefs = parseResult.mentionedHrefs;
|
|
98
52
|
}
|
|
99
53
|
else {
|
|
100
54
|
this.viewer.innerHTML = '';
|
|
55
|
+
this.mentionedHrefs = [];
|
|
101
56
|
}
|
|
102
57
|
}
|
|
103
58
|
}
|
|
104
59
|
__decorate([
|
|
105
60
|
observable
|
|
106
61
|
], RichTextViewer.prototype, "markdown", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
observable
|
|
109
|
-
], RichTextViewer.prototype, "childItems", void 0);
|
|
110
62
|
const nimbleRichTextViewer = RichTextViewer.compose({
|
|
111
63
|
baseName: 'rich-text-viewer',
|
|
112
64
|
template,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rich-text/viewer/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rich-text/viewer/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQnC;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAA5C;;QACI;;;;WAIG;QAEI,aAAQ,GAAG,EAAE,CAAC;QAOb,mBAAc,GAAa,EAAE,CAAC;IA4C1C,CAAC;IA1CG;;OAEG;IACa,iBAAiB;QAC7B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,oBAAoB;QACvB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAEM,iBAAiB;QACpB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAEO,UAAU;QACd,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE;YACnC,OAAO;SACV;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,MAAM,WAAW,GAAG,sBAAsB,CAAC,kBAAkB,CACzD,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAC1C,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClD,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;SACpD;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AAnDG;IADC,UAAU;gDACU;AAqDzB,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC;IAChD,QAAQ,EAAE,kBAAkB;IAC5B,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
2
|
import { display } from '@microsoft/fast-foundation';
|
|
3
|
-
import { bodyFont, bodyFontColor, linkFontColor } from '../../theme-provider/design-tokens';
|
|
3
|
+
import { bodyFont, bodyFontColor, linkFontColor, mentionFontColor } from '../../theme-provider/design-tokens';
|
|
4
4
|
export const styles = css `
|
|
5
5
|
${display('flex')}
|
|
6
6
|
|
|
@@ -11,6 +11,7 @@ export const styles = css `
|
|
|
11
11
|
width: auto;
|
|
12
12
|
overflow: auto;
|
|
13
13
|
height: 100%;
|
|
14
|
+
--ni-nimble-private-mention-font-color: ${mentionFontColor};
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.viewer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/rich-text/viewer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,QAAQ,EACR,aAAa,EACb,aAAa,
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/rich-text/viewer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,QAAQ,EACR,aAAa,EACb,aAAa,EACb,gBAAgB,EACnB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,MAAM,CAAC;;;gBAGL,QAAQ;;iBAEP,aAAa;;;;kDAIoB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;MAwB5D;AACE,gLAAgL,CAAC,EACrL;;;;;MAKE;AACE;;;;;;;GAOG,CAAC,EACR;;iBAEa,aAAa;;CAE7B,CAAC"}
|
|
@@ -4,19 +4,14 @@ import type { MappingConfig } from './models/mapping-config';
|
|
|
4
4
|
import type { RichTextMentionValidator, RichTextMentionValidity } from './models/mention-validator';
|
|
5
5
|
import { MentionInternals, MentionInternalsOptions } from './models/mention-internals';
|
|
6
6
|
import { Mapping } from '../../mapping/base';
|
|
7
|
-
export declare type MappingConfigs = ReadonlyMap<string, MappingConfig>;
|
|
8
|
-
export interface RichTextMentionConfig {
|
|
9
|
-
mappingConfigs: MappingConfigs;
|
|
10
|
-
}
|
|
11
7
|
/**
|
|
12
8
|
* The base class for Mention configuration
|
|
13
9
|
*/
|
|
14
|
-
export declare abstract class RichTextMention<
|
|
15
|
-
]> = RichTextMentionValidator<[]>> extends FoundationElement implements Subscriber {
|
|
10
|
+
export declare abstract class RichTextMention<TValidator extends RichTextMentionValidator = RichTextMentionValidator> extends FoundationElement implements Subscriber {
|
|
16
11
|
/**
|
|
17
12
|
* @internal
|
|
18
13
|
*/
|
|
19
|
-
readonly mentionInternals: MentionInternals
|
|
14
|
+
readonly mentionInternals: MentionInternals;
|
|
20
15
|
/** @internal */
|
|
21
16
|
readonly validator: TValidator;
|
|
22
17
|
/**
|
|
@@ -26,24 +21,30 @@ export declare abstract class RichTextMention<TMentionConfig extends RichTextMen
|
|
|
26
21
|
/** @internal */
|
|
27
22
|
mappingNotifiers: Notifier[];
|
|
28
23
|
/** @internal */
|
|
29
|
-
|
|
24
|
+
mappingElements: Mapping<unknown>[];
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
30
28
|
checkValidity(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
31
32
|
get validity(): RichTextMentionValidity;
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
emitMentionUpdate(filter: string): void;
|
|
32
37
|
/**
|
|
33
38
|
* @internal
|
|
34
39
|
*/
|
|
35
40
|
handleChange(source: unknown, args: unknown): void;
|
|
36
41
|
protected abstract createValidator(): TValidator;
|
|
37
42
|
protected abstract getMentionInternalsOptions(): MentionInternalsOptions;
|
|
38
|
-
protected abstract createMentionConfig(mappingConfigs: MappingConfigs): TMentionConfig;
|
|
39
43
|
protected abstract createMappingConfig(mapping: Mapping<unknown>): MappingConfig;
|
|
40
44
|
private getMappingConfigs;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*/
|
|
44
|
-
private updateMentionConfig;
|
|
45
|
-
private mappingsChanged;
|
|
45
|
+
private updateMappingConfigs;
|
|
46
|
+
private mappingElementsChanged;
|
|
46
47
|
private patternChanged;
|
|
47
|
-
private
|
|
48
|
-
private
|
|
48
|
+
private removeMappingElementObservers;
|
|
49
|
+
private observeMappingElements;
|
|
49
50
|
}
|
|
@@ -12,31 +12,48 @@ export class RichTextMention extends FoundationElement {
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
this.mentionInternals = new MentionInternals(this.getMentionInternalsOptions())
|
|
15
|
+
this.mentionInternals = new MentionInternals(this.getMentionInternalsOptions(), (filter) => {
|
|
16
|
+
this.emitMentionUpdate(filter);
|
|
17
|
+
});
|
|
16
18
|
/** @internal */
|
|
17
19
|
this.validator = this.createValidator();
|
|
18
20
|
/** @internal */
|
|
19
21
|
this.mappingNotifiers = [];
|
|
20
22
|
/** @internal */
|
|
21
|
-
this.
|
|
23
|
+
this.mappingElements = [];
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
23
28
|
checkValidity() {
|
|
24
29
|
return this.mentionInternals.validConfiguration;
|
|
25
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
26
34
|
get validity() {
|
|
27
35
|
return this.validator.getValidity();
|
|
28
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
emitMentionUpdate(filter) {
|
|
41
|
+
const mentionUpdateEventDetails = {
|
|
42
|
+
filter
|
|
43
|
+
};
|
|
44
|
+
this.$emit('mention-update', mentionUpdateEventDetails);
|
|
45
|
+
}
|
|
29
46
|
/**
|
|
30
47
|
* @internal
|
|
31
48
|
*/
|
|
32
49
|
handleChange(source, args) {
|
|
33
50
|
if (source instanceof Mapping && typeof args === 'string') {
|
|
34
|
-
this.
|
|
51
|
+
this.updateMappingConfigs();
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
54
|
getMappingConfigs() {
|
|
38
55
|
const mappingConfigs = new Map();
|
|
39
|
-
this.
|
|
56
|
+
this.mappingElements.forEach(mapping => {
|
|
40
57
|
const href = mapping.key ?? undefined;
|
|
41
58
|
if (href === undefined || typeof href !== 'string') {
|
|
42
59
|
throw Error('mentionHref was invalid for type. Validation should have prevented this.');
|
|
@@ -46,32 +63,29 @@ export class RichTextMention extends FoundationElement {
|
|
|
46
63
|
});
|
|
47
64
|
return mappingConfigs;
|
|
48
65
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.validator.validate(this.mappings, this.pattern);
|
|
54
|
-
this.mentionInternals.mentionConfig = this.validator.isValid()
|
|
55
|
-
? this.createMentionConfig(this.getMappingConfigs())
|
|
66
|
+
updateMappingConfigs() {
|
|
67
|
+
this.validator.validate(this.mappingElements, this.pattern);
|
|
68
|
+
this.mentionInternals.mappingConfigs = this.validator.isValid()
|
|
69
|
+
? this.getMappingConfigs()
|
|
56
70
|
: undefined;
|
|
57
71
|
}
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
72
|
+
mappingElementsChanged() {
|
|
73
|
+
this.updateMappingConfigs();
|
|
74
|
+
this.observeMappingElements();
|
|
61
75
|
}
|
|
62
76
|
patternChanged() {
|
|
77
|
+
this.validator.validate(this.mappingElements, this.pattern);
|
|
63
78
|
this.mentionInternals.pattern = this.pattern;
|
|
64
|
-
this.updateMentionConfig();
|
|
65
79
|
}
|
|
66
|
-
|
|
80
|
+
removeMappingElementObservers() {
|
|
67
81
|
this.mappingNotifiers.forEach(notifier => {
|
|
68
82
|
notifier.unsubscribe(this);
|
|
69
83
|
});
|
|
70
84
|
this.mappingNotifiers = [];
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
for (const mapping of this.
|
|
86
|
+
observeMappingElements() {
|
|
87
|
+
this.removeMappingElementObservers();
|
|
88
|
+
for (const mapping of this.mappingElements) {
|
|
75
89
|
const notifier = Observable.getNotifier(mapping);
|
|
76
90
|
notifier.subscribe(this);
|
|
77
91
|
this.mappingNotifiers.push(notifier);
|
|
@@ -83,5 +97,5 @@ __decorate([
|
|
|
83
97
|
], RichTextMention.prototype, "pattern", void 0);
|
|
84
98
|
__decorate([
|
|
85
99
|
observable
|
|
86
|
-
], RichTextMention.prototype, "
|
|
100
|
+
], RichTextMention.prototype, "mappingElements", void 0);
|
|
87
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rich-text-mention/base/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,IAAI,EAEJ,UAAU,EACV,UAAU,EAEb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,OAAO,EACH,gBAAgB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rich-text-mention/base/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,IAAI,EAEJ,UAAU,EACV,UAAU,EAEb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,OAAO,EACH,gBAAgB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;GAEG;AACH,MAAM,OAAgB,eAGlB,SAAQ,iBAAiB;IAH7B;;QAKI;;WAEG;QACa,qBAAgB,GAAqB,IAAI,gBAAgB,CACrE,IAAI,CAAC,0BAA0B,EAAE,EACjC,CAAC,MAAc,EAAQ,EAAE;YACrB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC,CACJ,CAAC;QAEF,gBAAgB;QACA,cAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAQnD,gBAAgB;QACT,qBAAgB,GAAe,EAAE,CAAC;QAEzC,g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AC,SAAS,CAAC,OAAO,EAAE;YAC3D,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC1B,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;IAEO,sBAAsB;QAC1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAClC,CAAC;IAEO,cAAc;QAClB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IACjD,CAAC;IAEO,6BAA6B;QACjC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACrC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC/B,CAAC;IAEO,sBAAsB;QAC1B,IAAI,CAAC,6BAA6B,EAAE,CAAC;QAErC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE;YACxC,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACjD,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxC;IACL,CAAC;CACJ;AAlGG;IADC,IAAI;gDACmB;AAOxB;IADC,UAAU;wDACqC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MappingConfigs, MentionUpdateEmitter } from '../types';
|
|
1
2
|
export interface MentionInternalsOptions {
|
|
2
3
|
readonly icon: string;
|
|
3
4
|
readonly character: string;
|
|
@@ -6,11 +7,11 @@ export interface MentionInternalsOptions {
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal mention state
|
|
8
9
|
*/
|
|
9
|
-
export declare class MentionInternals
|
|
10
|
+
export declare class MentionInternals {
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Mappings configured for the mention node
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
mappingConfigs?: MappingConfigs;
|
|
14
15
|
/**
|
|
15
16
|
* Whether this mention has a valid configuration.
|
|
16
17
|
*/
|
|
@@ -31,5 +32,9 @@ export declare class MentionInternals<TMentionConfig> {
|
|
|
31
32
|
* Mention view element to render in rich text components
|
|
32
33
|
*/
|
|
33
34
|
readonly viewElement: string;
|
|
34
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Function to invoke to emit a mention-update event
|
|
37
|
+
*/
|
|
38
|
+
readonly mentionUpdateEmitter: MentionUpdateEmitter;
|
|
39
|
+
constructor(options: MentionInternalsOptions, mentionUpdateEmitter: MentionUpdateEmitter);
|
|
35
40
|
}
|
|
@@ -4,7 +4,7 @@ import { observable } from '@microsoft/fast-element';
|
|
|
4
4
|
* Internal mention state
|
|
5
5
|
*/
|
|
6
6
|
export class MentionInternals {
|
|
7
|
-
constructor(options) {
|
|
7
|
+
constructor(options, mentionUpdateEmitter) {
|
|
8
8
|
/**
|
|
9
9
|
* Whether this mention has a valid configuration.
|
|
10
10
|
*/
|
|
@@ -12,12 +12,16 @@ export class MentionInternals {
|
|
|
12
12
|
this.icon = options.icon;
|
|
13
13
|
this.character = options.character;
|
|
14
14
|
this.viewElement = options.viewElement;
|
|
15
|
+
this.mentionUpdateEmitter = mentionUpdateEmitter;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
__decorate([
|
|
18
19
|
observable
|
|
19
|
-
], MentionInternals.prototype, "
|
|
20
|
+
], MentionInternals.prototype, "mappingConfigs", void 0);
|
|
20
21
|
__decorate([
|
|
21
22
|
observable
|
|
22
23
|
], MentionInternals.prototype, "validConfiguration", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
observable
|
|
26
|
+
], MentionInternals.prototype, "pattern", void 0);
|
|
23
27
|
//# sourceMappingURL=mention-internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-internals.js","sourceRoot":"","sources":["../../../../../src/rich-text-mention/base/models/mention-internals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"mention-internals.js","sourceRoot":"","sources":["../../../../../src/rich-text-mention/base/models/mention-internals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAuCzB,YACI,OAAgC,EAChC,oBAA0C;QAlC9C;;WAEG;QAEI,uBAAkB,GAAG,IAAI,CAAC;QAgC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACrD,CAAC;CACJ;AA3CG;IADC,UAAU;wDAC4B;AAMvC;IADC,UAAU;4DACsB;AAMjC;IADC,UAAU;iDACa"}
|