Copy Rich Text with Formatting in JS

HI - I’m writing a JS routine to copy projects within a space. I can copy the main description field for an entity, but the copied version only contains unformatted text.

Does anyone have a sample of the code to copy both the text and the formattng? I’ve been using a snippet @Yuri_BC wrote for what appears to be markdown:

async function fetchDocumentContent(documentSecret) {
    if (!documentSecret) {
        return null;
    }
    return await fibery.getDocumentContent(documentSecret, 'md');
}

let descriptionContent = null;
        if (entity[SOURCE_DESCRIPTION_FIELD] && entity[SOURCE_DESCRIPTION_FIELD].Secret) {
            descriptionContent = await fetchDocumentContent(entity[SOURCE_DESCRIPTION_FIELD].Secret);
        }

        // Set the 'Description' content for the new entity
        if (descriptionContent) {
            await fibery.setDocumentContent(newEntity[TARGET_DESCRIPTION_FIELD].Secret, descriptionContent, 'md');
        }

thx!

What’s missing? All formatting, or just some specific things?

May I ask - the code above appears to be specific for markdown. Is there corresponding code for ricj=h text?

source:

target:

There are some markdown formatting elements that are not supported when copying, e.g. callout blocks

  1. Is there any documentation that spells out what is supported? I use callouts extensively, but if there is an alternative, I can switch to supported rich text.

  2. Can you please confirm if the above code is correct for rich text? This seems to be specific to markdown:
    await fibery.setDocumentContent(newEntity[TARGET_DESCRIPTION_FIELD].Secret, descriptionContent, 'md');

I don’t think we have anything in our user guide. Will add it to the to-do list :frowning:

The code looks to be syntactically correct, but the ‘md’ option is just one of several (the others being ‘html’ and ‘json’) and if you’re copying within Fibery the html option supports more formatting options than markdown I believe.

Aha! Using JSON in both the fetch and set works! I haven’t tested deeply nested text, but 2 levels deep seems to work just fine.

Thanks you so much!