Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0 #559

Open
2 of 28 tasks
Mottie opened this issue May 5, 2017 · 4 comments
Open
2 of 28 tasks

Version 2.0 #559

Mottie opened this issue May 5, 2017 · 4 comments
Milestone

Comments

@Mottie
Copy link
Owner

Mottie commented May 5, 2017

I am planning on rewriting this plugin in plain JS or React. The following list are changes that are being planned. Please feel free to comment:

Remove

  • Remove jQuery dependency.
  • Remove built-in jQuery UI position utility support. Use the beforeVisible or visible callback to position it.
  • Remove position option - see above.
  • Remove customLayout option; The layout option will accept the custom layout instead.
  • Remove '{accept} {space} {cancel}' row from every language layout - we'll use the addRow method to add these instead (described below).

Change/Fix

  • Improved deadkey support. Allow various input methods:

  • Better support, demo and documentation for use with Codemirror - see Question: possible to use with codemirror, ace, etc? #306 & Codemirror and keyboard #551.

  • Better support, demo and documentation for use with Ace editor - see Question: possible to use with codemirror, ace, etc? #306.

  • Better support, demo and documentation for plugins like select2, chosen, selectator and selectize.js - see problem with select2 boxes #349 & keyboard special Key to call "chosen" with jquey data  #464.

  • Find a way to override the Alt key in Windows to allow switching keysets.

  • Use tabindex properly when switching inputs - see Option to keep select, checkboxes, .. in taborder #472.

  • Set display option to allow modifying the text of any key - see Replace label on key #555.

  • Split keyboard layouts, similar to the extender extension, but add to different containers like a split physical keyboard.

  • Expand keyaction definitions. Possible syntax:

    Keyboard.keyActions = {
    
      accept: {
        // action key aliases; can replace with a regular expression
        aliases: [ "{a}", "{accept}" ],
        // if null, get key content from language display definition;
        // if it doesn't exist, the keyAction name is used
        content: null,
        // extra class names added to key (defaults contained in Keyboard.css)
        classes: "accept-me",
        tooltip: "",
        // key action to perform
        action : function (kb) {
          kb.accept();
        },
        // add keys that are allowed to enter into the input/textarea if
        // `restrictInput` is set
        acceptedKeys: []
      },
    
      spacer: {
        aliases: [ /^\{sp:((\d+)?([\.|,]\d+)?)(em|px)?\}$/i ],
        content: function(kb, key) {
          // kb = keyboard object
          // key = alias minus the wrapping {}
          // not perfect globalization, but allows you to use
          // {sp:1,1em}, {sp:1.2em} or {sp:15px}
          let margin = parseFloat(key.replace(/,/, '.')
            .match(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/i)[1] || 0),
    
            // previously {sp:1} would add 1em margin to each side of a 0 width
            // span now Firefox doesn't seem to render 0px dimensions, so now we
            // set the 1em margin x 2 for the width
            width = (key.match(/px/i) ? margin + 'px' : (margin * 2) + 'em'),
    
            span = document.createElement('span');
    
          span.css.width = width;
          return span;
        },
        classes: "keyboard-spacer",
        tooltip: ""
        // action: null,
        // acceptedKeys: []
      },
    
      panic: {
        aliases: [ "{panic}", "{!!!}" ],
        content: "Panic!!!",
        classes: "keyboard-action-panic",
        tooltip: "",
        action: function (kb) {
          Modal.open({
            media: "assets/panic.mp4",
            onClose: function() {
              kb.insertText("Ahhhhh!");
            }
          });
        },
        acceptedKeys: "panic!".split("")
      }
    
    };
  • Add internal methods to change key/keyactions to auto-suggest characters (e.g. suggest Pinyin characters based on input - see pinyin support? #322).

  • Rename tabNavigation to tabBehavior and give it 3 options (see Pressing Tab button inserts indentation in textarea. How to prevent it? #692):

    • "disable" - do nothing
    • "insertTab" - textarea only
    • "navigate" - textarea & input

Add

  • Support for contenteditable elements - see Bind to DOM elements other than textarea and input. #208 & Keyboard not working with editable tables (contenteditable="true") #540.

  • Support for input masks - new, or integrate an existing masker? see bad conflict with maskedinput #89 & Input Mask Integration #201.

  • Allow initialization on the document & use a delegated binding on input/textarea - see Can it initialise globally? #558.

  • Better support, demo and documentation for use with Mathquill - see Mathquill for input area #423.

  • Wrap each row with a div to support row styling (e.g. row spacing).

  • Physical keyboard shortcuts?

  • Add layout & language selector to keyboard popup - see language pull down inside keyboard and dynamically loading script #110, Set language #355 & Can you add a keyboard layout change feature like this one? #532:

    • Allow chosing which layouts & languages to include.
    • Allow toggling the display of selectors.
    • Allow enable/disabling of these selectors.
  • Add a customizable tool bar:

    • Set location, e.g. across the top or bottom.
    • Include custom keys: lock/unlock, enable/disable, etc.
    • Include layout & language selectors.
  • Add a key:

    • Allows adding a key or action key to any layout without having to copy/paste a current layout and making it "custom".

    • Possible syntax:

      Keyboard.addKey("{test}", {
        // keyset(s); opts "all", "normal", "shift", "meta", etc
        // should allow multiple settings, e.g. "normal,shift" (add to 2+ keysets)
        to: "all",
        // where to add row & column (zero-based index)
        row: 0,
        column: 0
      });
  • Add a row:

    • Allows adding a row of keys to any layout without having to copy/paste a current layout and making it "custom".

    • Possible syntax:

      Keyboard.addRow("{accept} {space} {cancel}", {
        // keyset(s); opts "all", "normal", "shift", "meta", etc
        // should allow multiple settings, e.g. "normal,shift" (add to 2+ keysets)
        to: "all",   
        // where to add the row
        // "append", "prepend", or "2" (zero-based row index)
        loc: "append"
      });
  • Replace a row

    • Allows replacing an existing row of keys in any layout without having to copy/paste a current layout and making it "custom".

    • Similar to javascript .replace() and allow using regular expressions to match a row.

    • Possible syntax:

      // syntax: replaceRow({original row}, {new row});
      Keyboard.replaceRow("{accept} {space} {cancel}", "{a} {space} {c}");
      // or
      Keyboard.replaceRow(/\{accept\}/g, "{a} {space} {c}");
  • Remove a button from a defined layout

@Mottie Mottie added this to the Version 2.0 milestone May 5, 2017
@jbotte
Copy link

jbotte commented Jun 30, 2017

Love the idea of plain js!

@squarism
Copy link

In terms of plain js, do you mean you'd just traverse and manipulate the DOM using some modern browser baseline? Or would you split out the project into plain javascript objects (like a lib) and then have bindings to jquery or react? Even if you didn't tackle the bindings bits, having a library would make creating a mottie-react project sort of easier. The component would just include the library and invoke functions. CSS would be in the react binding project. All the logic / layout / human language details would be in the lib maybe? Is this close or just rambling?

@Mottie
Copy link
Owner Author

Mottie commented Apr 25, 2018

Hi @squarism!

I was actually thinking to build it as a library that can be used just like that... then I, with help, could build adapters for other libraries.

@exylzior
Copy link

exylzior commented Nov 15, 2018

Good Day ! ! !

I'm trying to use your library in a React but I'm having some difficulty in using the example as reference because it uses gives a Jquery example do you have React Examples ?

@Mottie Mottie pinned this issue Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants