@impro.social/impro-plugin 0.0.10 → 0.0.11
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/main.js +8 -1
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -316,7 +316,10 @@ export class Plugin {
|
|
|
316
316
|
// callback(tokens, context) receives the rich-text token stream for one
|
|
317
317
|
// post and returns a new token array (or the input unchanged). The host
|
|
318
318
|
// batches all posts of a render into one call per plugin.
|
|
319
|
-
|
|
319
|
+
//
|
|
320
|
+
// options.handlesFacetTypes: array of facet feature $type strings this
|
|
321
|
+
// transform owns, to prevent render flash of fallback text
|
|
322
|
+
registerRichTextTransform(callback = (tokens) => tokens, options = {}) {
|
|
320
323
|
const handlerId = uuid.create();
|
|
321
324
|
callHandlers.set(handlerId, async (batch) => {
|
|
322
325
|
const results = [];
|
|
@@ -330,10 +333,14 @@ export class Plugin {
|
|
|
330
333
|
}
|
|
331
334
|
return results;
|
|
332
335
|
});
|
|
336
|
+
const handlesFacetTypes = Array.isArray(options.handlesFacetTypes)
|
|
337
|
+
? options.handlesFacetTypes.filter((type) => typeof type === "string")
|
|
338
|
+
: [];
|
|
333
339
|
self.postMessage({
|
|
334
340
|
type: "register",
|
|
335
341
|
target: "richTextTransform",
|
|
336
342
|
handlerId,
|
|
343
|
+
handlesFacetTypes,
|
|
337
344
|
});
|
|
338
345
|
}
|
|
339
346
|
|