reverseqr

qr codes working in both directions
git clone https://tongong.net/git/reverseqr.git
Log | Files | Refs | README

edit-view.js (878B)


      1 const m = require("mithril");
      2 const { TextAreaBinding } = require("y-textarea");
      3 
      4 const store = require("../modules/store.js");
      5 
      6 module.exports = () => {
      7     return {
      8         view: () => m(".page",
      9             m(".main.absolute-center", m("textarea.maxsize", {
     10                 oncreate: (v) => {
     11                     let binding = null;
     12                     store.subscribe(s => s.ydoc, ydoc => {
     13                         if (binding) binding.destroy();
     14                         binding = new TextAreaBinding(
     15                             ydoc.getText("shared-buffer"), v.dom);
     16                     }, { fireImmediately: true });
     17                     store.subscribe(s => s.qr, (qrn, qro) => {
     18                         if (!qrn && qro) {
     19                             v.dom.focus();
     20                         }
     21                     });
     22                 },
     23             })),
     24         )
     25     }
     26 };