Autoconvert

Autoconvert allows your macro to be inserted into the editor when a recognised URL is pasted in by the user. You define recognised URL patterns using 'matchers' which are registered in the editor when your add-on is installed.

When the macro is created in the editor, the URL string that triggered the autoconvert will be captured and inserted as a parameter on the macro body. You must define the name of this parameter by providing a string value for 'urlParameter'. This allows you to access the URL that triggered the autoconvert.

Example

This example inserts a macro into the editor when a user pastes in certain simple Facebook links.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
  "renderModes": {},
  "url": "/dynamic-macro?url={url}",
  "categories": [],
  "outputType": "block",
  "bodyType": "none",
  "aliases": [],
  "parameters": [
    {
      "identifier": "url",
      "name": {
        "value": "URL"
      },
      "type": "string",
      "required": false,
      "multiple": false,
      "hidden": false
    }
  ],
  "autoconvert": {
    "urlParameter": "url",
    "matchers": [
      {
        "pattern": "https://www.facebook.com/{}/about"
      },
      {
        "pattern": "https://www.facebook.com/{}/music"
      },
      {
        "pattern": "https://www.facebook.com/{}/movies/{}"
      }
    ]
  },
  "name": {
    "value": "Dynamic Macro With Autoconvert"
  },
  "key": "dynamic-macro-with-autoconvert"
}

Properties

urlParameter
Type
Max length
100
Required
Yes
Description

The name of the macro parameter the matched url will be inserted into.


matchers
Type
Description

The list of patterns that define what URLs should be matched.


Rate this page: