{
  "name": "Selection Base64",
  "description": "Highlight text, right-click, and get both its Base64 encoding and decoding — the encoded value is copied for you.",
  "tags": [
    "base64",
    "encode",
    "decode",
    "selection",
    "right-click",
    "developer"
  ],
  "type": "triggered",
  "nodes": [
    {
      "id": "sticky-intro",
      "position": {
        "x": 20,
        "y": 20
      },
      "data": {
        "color": "#fff266",
        "content": "🔡 Base64 encode and decode a selection.\n\nHighlight any text, right-click, and choose this workflow. It shows both the Base64-encoded and Base64-decoded versions of your selection and copies the encoded value to your clipboard. Runs entirely in your browser."
      },
      "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": "convert",
      "position": {
        "x": 440,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:code"
        },
        "label": "Encode and decode",
        "inputs": {
          "code": "import base64\nsel = input.get('selection', '') if isinstance(input, dict) else str(input)\nencoded = base64.b64encode(sel.encode('utf-8')).decode('ascii')\ntry:\n    decoded = base64.b64decode(sel.encode('utf-8'), validate=True).decode('utf-8')\nexcept Exception:\n    decoded = '(selection is not valid base64)'\nout = {'original': sel, 'encoded': encoded, 'decoded': decoded}\nout"
        },
        "parameters": {
          "notes": "Python: Base64-encodes your selection and also tries to decode it as Base64. The last line is the result."
        }
      },
      "type": "basic"
    },
    {
      "id": "copy-encoded",
      "position": {
        "x": 760,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:clipboardWriteNode"
        },
        "label": "Copy the encoded value",
        "inputs": {
          "text": "{{ $input.result.encoded }}"
        },
        "parameters": {
          "notes": "Copies the Base64-encoded value to your clipboard."
        }
      },
      "type": "basic"
    },
    {
      "id": "show-both",
      "position": {
        "x": 760,
        "y": 480
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:displayObjectNode"
        },
        "label": "Show both results",
        "inputs": {
          "title": "Base64 encode / decode"
        },
        "parameters": {
          "notes": "Displays the original, encoded, and decoded values side by side."
        }
      },
      "type": "basic"
    }
  ],
  "edges": [
    {
      "id": "e-ctx-get-selection",
      "type": "flowEdge",
      "source": "trigger-context-menu",
      "target": "get-selection"
    },
    {
      "id": "e-trigger-convert",
      "type": "flowEdge",
      "source": "get-selection",
      "target": "convert"
    },
    {
      "id": "e-convert-copy",
      "type": "flowEdge",
      "source": "convert",
      "target": "copy-encoded"
    },
    {
      "id": "e-convert-show",
      "type": "flowEdge",
      "source": "convert",
      "target": "show-both"
    }
  ]
}