diff --git a/packages/plugins/blocks/blocks-qr/README.md b/packages/plugins/blocks/blocks-qr/README.md index 5ef4563dc..7d038782c 100644 --- a/packages/plugins/blocks/blocks-qr/README.md +++ b/packages/plugins/blocks/blocks-qr/README.md @@ -1 +1,42 @@ -# Lowdefy QR blocks +# Lowdefy QR Blocks + +This is a Lowdefy blocks wrapper for the [HTML5 QR code & barcode reader](https://github.com/mebjas/html5-qrcode). + +See the [HTML5 QR code docs](https://github.com/mebjas/html5-qrcode#documentation) for the scanner config. + +When a code is scanned by the QR scanner, the value of the block is set to the decoded result from the scan. The value is an object, which has the following fields: + +- `decodedText: string;` +- `result: QrcodeResult;` + +### Properties + +- `fps: number`: Expected framerate of QR code scanning. +- `qrbox: number | {width: number, height: number}`: The dimensions for the QR scanning area. If not set, the entire area of the video stream will be used by the scanner. +- `aspectRatio: number`: The aspect ratio for the video. +- `disableFlip: boolean`: Disable the ability to scan QR codes that have been flipped. +- `formatsToSupport: List of Html5QrcodeSupportedFormats`: Limit the code formats that can be scanned. See [Html5QrcodeSupportedFormats](https://github.com/mebjas/html5-qrcode#documentation:~:text=library.%0A%20*/%0Aenum-,Html5QrcodeSupportedFormats,-%7B%0A%20%20QR_CODE%20%3D). +- `style: cssObject`: A style object applied to the scanner element. + +### Events + +- `onScan`: Trigger onScan actions when a qr code is scanned. + +### Methods + +- `start`: Start the QR scanner. +- `stop`: Stop the QR scanner. + +## Examples + +1. Simple use of QRScanner + +```yaml +- id: qr_scanner + type: QRScanner +``` + +To obtain the result from the scan use: +```yaml + _state: qr_scanner +``` diff --git a/packages/plugins/blocks/blocks-qr/src/blocks/QRScanner/schema.json b/packages/plugins/blocks/blocks-qr/src/blocks/QRScanner/schema.json new file mode 100644 index 000000000..312ef609a --- /dev/null +++ b/packages/plugins/blocks/blocks-qr/src/blocks/QRScanner/schema.json @@ -0,0 +1,65 @@ +{ + "type": "object", + "properties": { + "type": "object", + "additionalProperties": false, + "properties": { + "fps": { + "type": "number", + "description": "Expected framerate of QR code scanning" + }, + "qrbox": { + "type": ["number", "object"], + "description": "The dimensions for the QR scanning area. If not set, the entire area of the video stream will be used by the scanner." + }, + "aspectRatio": { + "type": "float", + "description": "The aspect ratio for the video." + }, + "disableFlip": { + "type": "boolean", + "description": "Disable the ability to scan QR codes that have been flipped." + }, + "formatsToSupport": { + "type": "array", + "description": "List of Html5QrcodeSupportedFormats to support. See more.", + "items": { + "type": "number", + "enum": [ + "QR_CODE = 0", + "AZTEC", + "CODABAR", + "CODE_39", + "CODE_93", + "CODE_128", + "DATA_MATRIX", + "MAXICODE", + "ITF", + "EAN_13", + "EAN_8", + "PDF_417", + "RSS_14", + "RSS_EXPANDED", + "UPC_A", + "UPC_E", + "UPC_EAN_EXTENSION" + ] + } + }, + "style": { + "type": "object", + "description": "Custom css properties to apply to scanner block." + } + } + }, + "events": { + "type": "object", + "additionalProperties": false, + "properties": { + "onScan": { + "type": "array", + "description": "Trigger actions when code is scanned." + } + } + } +}