Coder Social home page Coder Social logo

Comments (2)

SychO9 avatar SychO9 commented on June 2, 2024

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.

from framework.

n-peugnet avatar n-peugnet commented on June 2, 2024

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 (club-1/flarum-ext-cross-references#4).

As explained in s9e/TextFormatter#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:

const updatePreview = () => {
// Since we're polling, the composer may have been closed in the meantime,
// so we bail in that case.
if (!this.attrs.composer.isVisible()) return;
const content = this.attrs.composer.fields.content();
if (preview === content) return;
preview = content;
this.attrs.surround(() => s9e.TextFormatter.preview(preview || '', vnode.dom));
};

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.