@vector-im/matrix-wysiwyg 2.37.13 → 2.38.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/README.md CHANGED
@@ -40,6 +40,13 @@ Requirements:
40
40
  yarn install
41
41
  ```
42
42
 
43
+ If your environment supports the experimental [ES Module Integration Proposal for WebAssembly](https://github.com/WebAssembly/esm-integration),
44
+ you can instead use that, by setting the `matrix-org:wasm-esm` custom [export condition](https://nodejs.org/api/packages.html#conditional-exports).
45
+ This is only supported when the library is imported as an ES Module. For example:
46
+ - In Webpack, set [`experiments.asyncWebAssembly`](https://webpack.js.org/configuration/experiments/#experiments)
47
+ to `true` and [`resolve.conditionNames`](https://webpack.js.org/configuration/resolve/#resolveconditionnames)
48
+ to `["matrix-org:wasm-esm", "..."]` (the `"..."` preserves default condition names).
49
+
43
50
  ### Dev
44
51
 
45
52
  #### Folder structure
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComposerUpdate } from '@vector-im/matrix-wysiwyg-wasm';
1
2
  import { RefObject } from 'react';
2
3
 
3
4
  export declare const ACTION_TYPES: readonly ["bold", "italic", "strikeThrough", "underline", "undo", "redo", "orderedList", "unorderedList", "inlineCode", "clear", "link", "codeBlock", "quote", "indent", "unindent"];
@@ -12,24 +13,6 @@ export declare type AllowedMentionAttributes = Map<'style' | 'data-mention-type'
12
13
 
13
14
  export declare type BlockType = InputEvent['inputType'] | 'formatInlineCode' | 'clear';
14
15
 
15
- /**
16
- */
17
- export declare class ComposerUpdate {
18
- free(): void;
19
- /**
20
- * @returns {TextUpdate}
21
- */
22
- text_update(): TextUpdate;
23
- /**
24
- * @returns {MenuState}
25
- */
26
- menu_state(): MenuState;
27
- /**
28
- * @returns {MenuAction}
29
- */
30
- menu_action(): MenuAction;
31
- }
32
-
33
16
  export declare type FormattingFunctions = Record<Exclude<ActionTypes, 'link'>, () => void> & {
34
17
  insertText: (text: string) => void;
35
18
  link: (url: string, text?: string) => void;
@@ -40,13 +23,12 @@ export declare type FormattingFunctions = Record<Exclude<ActionTypes, 'link'>, (
40
23
  getLink: () => string;
41
24
  };
42
25
 
43
- export declare type InputEventProcessor = (event: WysiwygEvent, wysiwyg: Wysiwyg, editor: HTMLElement) => WysiwygEvent | null;
44
-
45
26
  /**
27
+ * Initialise the WASM module, or do nothing if it is already initialised.
46
28
  */
47
- export declare class Keep {
48
- free(): void;
49
- }
29
+ export declare function initOnce(): Promise<void>;
30
+
31
+ export declare type InputEventProcessor = (event: WysiwygEvent, wysiwyg: Wysiwyg, editor: HTMLElement) => WysiwygEvent | null;
50
32
 
51
33
  export declare type LinkEvent = Omit<InputEvent, 'data'> & {
52
34
  inputType: 'insertLink';
@@ -62,147 +44,16 @@ export declare type MappedSuggestion = {
62
44
  type: SuggestionType;
63
45
  };
64
46
 
65
- /**
66
- */
67
- export declare class MenuAction {
68
- free(): void;
69
- /**
70
- * @returns {boolean}
71
- */
72
- keep(): boolean;
73
- /**
74
- * @returns {boolean}
75
- */
76
- none(): boolean;
77
- /**
78
- * @returns {MenuActionSuggestion | undefined}
79
- */
80
- suggestion(): MenuActionSuggestion | undefined;
81
- }
82
-
83
- /**
84
- */
85
- export declare class MenuActionSuggestion {
86
- free(): void;
87
- /**
88
- */
89
- suggestion_pattern: SuggestionPattern;
90
- }
91
-
92
- /**
93
- */
94
- export declare class MenuState {
95
- free(): void;
96
- /**
97
- * @returns {boolean}
98
- */
99
- keep(): boolean;
100
- /**
101
- * @returns {MenuStateUpdate | undefined}
102
- */
103
- update(): MenuStateUpdate | undefined;
104
- }
105
-
106
- /**
107
- */
108
- export declare class MenuStateUpdate {
109
- free(): void;
110
- /**
111
- */
112
- action_states: Map<any, any>;
113
- }
114
-
115
- /**
116
- */
117
- export declare class PatternKey {
118
- free(): void;
119
- /**
120
- */
121
- custom_key_value?: string;
122
- /**
123
- */
124
- key_type: PatternKeyType;
125
- }
126
-
127
- /**
128
- */
129
- export declare enum PatternKeyType {
130
- At = 0,
131
- Hash = 1,
132
- Slash = 2,
133
- Custom = 3,
134
- }
135
-
136
47
  export declare function plainToRich(plainText: string, inMessageFormat: boolean): Promise<string>;
137
48
 
138
- /**
139
- */
140
- export declare class ReplaceAll {
141
- free(): void;
142
- /**
143
- */
144
- end_utf16_codeunit: number;
145
- /**
146
- */
147
- replacement_html: string;
148
- /**
149
- */
150
- start_utf16_codeunit: number;
151
- }
152
-
153
49
  export declare function richToPlain(richText: string, inMessageFormat: boolean): Promise<string>;
154
50
 
155
- /**
156
- */
157
- export declare class Selection_2 {
158
- free(): void;
159
- /**
160
- */
161
- end_utf16_codeunit: number;
162
- /**
163
- */
164
- start_utf16_codeunit: number;
165
- }
166
-
167
51
  export declare type SuggestionChar = (typeof SUGGESTIONS)[number] | '';
168
52
 
169
- /**
170
- */
171
- export declare class SuggestionPattern {
172
- free(): void;
173
- /**
174
- */
175
- end: number;
176
- /**
177
- */
178
- key: PatternKey;
179
- /**
180
- */
181
- start: number;
182
- /**
183
- */
184
- text: string;
185
- }
186
-
187
53
  export declare const SUGGESTIONS: readonly ["@", "#", "/", ""];
188
54
 
189
55
  export declare type SuggestionType = 'mention' | 'command' | 'custom' | 'unknown';
190
56
 
191
- /**
192
- */
193
- export declare class TextUpdate {
194
- free(): void;
195
- /**
196
- */
197
- keep?: Keep;
198
- /**
199
- */
200
- replace_all?: ReplaceAll;
201
- /**
202
- */
203
- select?: Selection_2;
204
- }
205
-
206
57
  export declare type TraceAction = (update: ComposerUpdate | null, name: string, value1?: string | number, value2?: string | number) => ComposerUpdate | null;
207
58
 
208
59
  export declare type UseWysiwyg = {