[IN DEV] Easy import of markdown docs to wiki

Hello - I have a considerable number of docs in markdown. The wiki docs / other docs, is not really compatible with simply copy-pasting markdown you have.

Anything that can be done?

Wiki doesn’t support copy-pasting markdown at the moment.
The workaround I can offer now is to use direct fibery api to update whole document with markdown content: https://api.fibery.io/#update-rich-text-field

1 Like

ah, right, that will work. Actually my docs are in a database and happen to be in markdown format in a text field. I can get a json dump of them, then use jq to cook up a script to push them in via curl. Problem is slogging through to figure out what is useful or not. :slight_smile:

This is indeed , the notion app well made as well embed , but maker user experience for non code user who did not know makdown format

As a general comment being able to paste markdown would be rather nice, especially for us people who write notes in markdown in text editors and then want to paste them quickly in.

(e.g. customer raises an issue on the phone, and I capture some notes in using a text editor)

1 Like

With the recent idea of using Fibery for public docs and other things, it seems like being able to get any existing docs into Fibery will be important. Most people will not want to use API for this. At a minimum markdown pasting should be supported. And ideally bulk Markdown import to map to individual Docs (or even entities+rich text?) would be great. Few companies are going to have no existing docs, and so they will want to move such docs into Fibery in the most efficient way.

4 Likes

I’m getting close to doing a big migration of multiple processes and 100s of associated docs into Fibery, or rather I’m wanting to do this, but have no ability to utilize the API myself (not a coder). This kind of import option, or at least a basic markdown paste interpretation, seems increasingly vital as Fibery positions itself more and more as a documentation, etc. solution. I know there is a lot going on, but can some useful aspect of this work be prioritized?

Or is there at least a workaround, like can I put all my docs into a CSV and import to Entity Rich Text that way? I know I could test it, but would appreciate an official answer rather than having to do some data wrangling to test it. :smile:

1 Like

OK, well… there’s a workaround that might be manageable for a short while, if you use a Database for your “docs” (which IMO is often a good idea anyway):

  • Create a Button that Overwrites (or appends/prepends, if you prefer) your Entity Description
  • Enable “Ask for user input” for the contents
  • Copy markdown from source, invoke button, paste, complete

Hey, magic, you have markdown “import”! It’s slow, it’s clunky, but… it works better than trying to just paste directly into the description (which does not work at all). :smile:

And if you really need it in a Doc, you can now successfully copy/paste with formatting from the Entity Description to a Doc. Highly ironic that this works, but markdown copy/paste does not, especially given that Fibery more or less supports markdown. :roll_eyes:

If the contents of the docs are not too big, you can actually do the following:
- create a simple text field (called ‘Scratchpad’ or something)
- define an automation that copies contents of this simple text field to the rich text field you want to use, whenever the simple text field is updated
- import the text/markdown into the simple text field, using CSV import

Ignore this!

1 Like

Hmm, OK that’s good to know. But can’t I just import to a Rich Text/Description field anyway? From a quick test import (without actually committing the data) it appears that Rich Text is available for mapping from source data. Am I missing something?

You’re absolutely right - it is possible to directly import into rich text. My fault for not checking that first - I had used the method suggested a while back for a different reason; I can’t recall if import to rich text was available at that time.
So yeah, if your source text is formatted as markdown correctly, then you should have no problems. Sorry for the confusion.

1 Like

Ah good, no worries! It’s a reasonable approach. I still strongly wish for at least single import (or copy/paste handling) for markdown into docs, and ideally bulk import of .md files to docs. It’s such a simple format and Fibery already mostly supports it. It could be a big help for people trying to migrate into Fibery from other tools = sales driver!

1 Like

I second this need. Migrating my team from Notion, we have a few hundred pages (FAQ, internal documentation, specifications …) which would be a pain to move to Fibery.

Only workaround I have for now is

  • export from notion as markdown + image (one zip file for a space or folder)
  • open folder in an IDE such as IntelliJ
  • open each page as markdown viewer
  • select all, copy
  • open proper page in fibery, paste (which thanksfully keeps most formatting and inserts images)

I’d really appreciate a way to automate this process.

2 Likes

I’ve started work on a script which would automate this migration from a notion export (basically any folder with markdown and picture files, similar to what you would share on github/gitlab …).

What works

  • updating a rich text field from a markdown file
curl -X POST https://colisweb.fibery.io/api/commands \
     -H 'Authorization: Token SECRET' \
     -H 'Content-Type: application/json' \
     -d \
      '[
         {
           "command": "fibery.entity/query",
           "args": {
             "query": {
               "q/from": "Produit/Solution",
               "q/select": [
                 "fibery/id",
                 "Produit/Name",
                 { "Produit/Description": [ "Collaboration~Documents/secret" ] }
               ],
               "q/where": ["=", ["Produit/Name"], "$name" ],
               "q/limit": 2
             },
              "params": {
              "$name": "Test End 2 End Suivi de colis"
            }
           }           
         }
      ]'

jq '.content =  $md' --arg md "$(< /tmp/md)"  --null-input > /tmp/json

# use fibery/id from previous command

curl -X PUT https://colisweb.fibery.io/api/documents/$fiberyId?format=md \
     -H 'Authorization: Token SECRET' \
     -H 'Content-Type: application/json' \
     -d "$(</tmp/json)"
  • uploading an image to fibery
curl -X POST https://colisweb.fibery.io/api/files \
     -H 'Authorization: Token SECRET' \
     -H 'content-type: multipart/form-data' \
     -F 'file=@/tmp/Untitled.png'

Where I need help

How can I use the uploaded png file in the markdown rich-text field ?
IE, how to I replace ![Untitled](/Untitled.png) in my original markdown file ?

1 Like

I found the answer by peeking at the network view when doing it by hand, it is simply
![Untitled](/api/files/ba511eea-f8bb-447e-9fda-b8c5fddfaa22)

(with “fibery/secret”: “ba511eea-f8bb-447e-9fda-b8c5fddfaa22” in the answer to the upload request)

3 Likes

I’ve made great progress on one area : I can now with this script (it’s scala but you should be able to port it easily to python or javascript) update all the entities with markdown + images, in a chosen field.

I’m now struggling with creating documents and folders from the API. I have not found documentation here and based on these posts I’m worried if this is possible.

Maybe @Oleg or @Chr1sG you could clarifiy the status about the API for managing documents and folders ?

2 Likes

Hi, @Michel_Daviot

Please find my js function to create/update docs

    const getDocumentsBatchCommand = (command) => async ({client, format, args}) => {
        logger.info(`[Fibery API]: Collab doc command: ${command} with ${args.length} ${format} docs`);
        return client.post(`api/documents/commands`, {
            searchParams: {
                ratelimit: 'on',
                format,
            },
            json: {
                command,
                args,
            },
            headers: await getAuth(),
        });
    };
    const updateDocuments = getDocumentsBatchCommand('create-or-update-documents');
    const appendDocuments = getDocumentsBatchCommand('create-or-append-documents');

where format is one of md, json, html or text

and args is array of elements which looks like

{
            secret: `XX-YY-ZZZ-it is just a doc secret`,
            content:`Hello`
 }
3 Likes

Please find below an example of creating folder

    const createFolder = async ({client, app, name, parent = null, publicId = null}) => {
        const operationId = uuid.v4();
        const folderId = uuid.v4();
        const result = await client.post(`api/views/json-rpc`, {
            json: {
                jsonrpc: `2.0`,
                method: `create-folders`,
                params: {
                    values: [
                        {
                            'fibery/Parent Folder': parent,
                            'fibery/id': folderId,
                            'fibery/name': name,
                            'fibery/container-app': {'fibery/id': app.id},
                            'fibery/public-id': publicId,
                        },
                    ],
                },
                id: operationId,
            },
            headers: await getAuth(),
        });
        if (result.error) {
            throw new Error(result.error.message);
        }
        return _.get(result, `result[0]`);
    };

In my code call looks like

const folder = await fibery.createFolder({
    app: app,
    name: folderName,
    parent: {'fibery/id': getFiberyId(step)},
});

3 Likes

I’ve added some documentation to the script. Also here is how I export from notion :
image

Thanks @Oleg I’ll try those to upload the rest of my data !

1 Like

@Michel_Daviot

Nice, I believe we will add support for integration apps in future to allow the import of documents and folders. It is partly implemented, but I am waiting for fibery core implementation of sub-documents.

1 Like