{
  "name": "Selection to QR Code",
  "description": "Highlight any text or link, right-click, and instantly get a scannable QR code you can view and download.",
  "tags": [
    "qr code",
    "selection",
    "generate",
    "share",
    "right-click",
    "download"
  ],
  "type": "triggered",
  "nodes": [
    {
      "id": "sticky-intro",
      "position": {
        "x": 20,
        "y": 20
      },
      "data": {
        "color": "#fff266",
        "content": "🔳 Turn a selection into a QR code.\n\nHighlight some text or a link on any page, right-click, and choose this workflow. It builds a QR image from your selection, shows it right there, and downloads it as a PNG. Runs anywhere, no account."
      },
      "type": "stickyNote",
      "width": 360,
      "height": 190
    },
    {
      "id": "trigger-context-menu",
      "position": {
        "x": 120,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:trigger:contextMenu"
        },
        "label": "Right-click a selection",
        "inputs": {
          "contexts": [
            "selection"
          ]
        },
        "parameters": {
          "notes": "Adds this workflow to the right-click menu whenever you have text selected."
        }
      },
      "type": "trigger"
    },
    {
      "id": "get-selection",
      "position": {
        "x": 420,
        "y": 470
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:getSelectedTextNode"
        },
        "label": "Get selected text",
        "inputs": {
          "outputFieldName": "selection",
          "options": {
            "includeInputFields": true
          }
        },
        "parameters": {
          "notes": "Reads the full text you highlighted on the page. The context-menu event only carries a short, truncated copy, so this node gets the complete selection reliably."
        }
      },
      "type": "basic"
    },
    {
      "id": "build-qr-url",
      "position": {
        "x": 440,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:code"
        },
        "label": "Build the QR link",
        "inputs": {
          "code": "import urllib.parse\nsel = input.get('selection', '') if isinstance(input, dict) else str(input)\nsel = sel.strip() or 'awflow'\nurl = 'https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=' + urllib.parse.quote(sel)\nout = {'selection': sel, 'qrUrl': url, 'markdown': '![QR code](' + url + ')'}\nout"
        },
        "parameters": {
          "notes": "Python: URL-encodes your selection and builds a QR image link plus a markdown image tag. The last line is the result."
        }
      },
      "type": "basic"
    },
    {
      "id": "show-qr",
      "position": {
        "x": 760,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:displayMarkdownNode"
        },
        "label": "Show the QR code",
        "inputs": {
          "title": "QR code",
          "content": "{{ $input.result.markdown }}"
        },
        "parameters": {
          "notes": "Displays the generated QR code image right where you're working."
        }
      },
      "type": "basic"
    },
    {
      "id": "download-qr",
      "position": {
        "x": 760,
        "y": 480
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:downloadAsFile"
        },
        "label": "Download the PNG",
        "inputs": {
          "fieldPath": "result.qrUrl",
          "fileType": "png",
          "fileName": "qr"
        },
        "parameters": {
          "notes": "Saves the QR code image to your downloads as a PNG file."
        }
      },
      "type": "basic"
    }
  ],
  "edges": [
    {
      "id": "e-ctx-get-selection",
      "type": "flowEdge",
      "source": "trigger-context-menu",
      "target": "get-selection"
    },
    {
      "id": "e-trigger-build",
      "type": "flowEdge",
      "source": "get-selection",
      "target": "build-qr-url"
    },
    {
      "id": "e-build-show",
      "type": "flowEdge",
      "source": "build-qr-url",
      "target": "show-qr"
    },
    {
      "id": "e-build-download",
      "type": "flowEdge",
      "source": "build-qr-url",
      "target": "download-qr"
    }
  ]
}