Open n-peugnet opened 1 year ago
It's not clear to me what it is you're trying to do or why you need an async call in the filter. I don't consider this a bug at the moment, it seems more like feature.
Can you please explain your use case.
I don't consider this a bug at the moment, it seems more like feature.
Sorry you're right, this is not exactly a bug request. But as it was a technical request for the extension API, the bug tracker seemed more adequate.
It's not clear to me what it is you're trying to do or why you need an async call in the filter. Can you please explain your use case.
I am writing an extension that modifies the content of CommentPosts. Among other features, it replaces bare links to discussions into a link that contains the title of the discussion. For now this is done in the frontend.
To make the modifications in the backend instead, and to get a preview of the modifications while writing a post, I figured that I needed to add a TextFormatter configuration (https://github.com/club-1/flarum-ext-cross-references/issues/4).
As explained in https://github.com/s9e/TextFormatter/issues/208, I need to make an asynchronous call in the Javascript part of the filter, in order to fetch the title of the discussion from the API (using app.store.find()
). But TextFormatter filters only works synchronously, so I was pointed to refreshing the preview once the Promise resolves.
This is indeed working, as I tried to modify the content of the composer using app.composer.editor.insertAt()
to trigger a refresh. But I would need to refresh the preview without editing the content of the composer.
From what I see here (ligne 40) there seem to be no way to trigger a refresh with an unchanged content: https://github.com/flarum/framework/blob/fe8480c8f73214ce7a5bc66792d74f5646692244/framework/core/js/src/forum/components/ComposerPostPreview.js#L33-L45
Current Behavior
TextFormatter does not allow to use asynchronous calls in the Javascript part of a filter, so I need to refresh the preview once the Promise is resolved (see https://github.com/s9e/TextFormatter/issues/208), but there is currently no way to do this in Flarum.
Steps to Reproduce
Expected Behavior
There should be some kind of function, maybe in
EditorDriverInterface
, or directly inapp.composer
(ComposerState
).Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
No response
Additional Context
No response