Flyter

A Javascript library for inline editing

inspired by x-editable but coded in Typescript without jquery, extendable and highly customizable.

flyter.attach('.ftr', 'text');
Github & Documentation

Four different types by default: text, checkboxes, radio and select

Flyter provides two renderers by default, popup and inline mode

Lot of configuration and customization options and callbacks available

Asynchronous callbacks on loading, rendering, initialization and more

Documentation

The latest documentation can be found on the github repo page.

Github & Documentation

Examples

Configuring through javascript object
flyter.attach('#ex-doc', {
  initialValue: ['1'],
  emptyValueDisplay: "I'm not feeling anything today",
  type: {
    name: 'checkbox',
    config: {
      dataSource: [
        { label: '😊', value: '1' },
        { label: '❤️', value: '2' },
        { label: '🔥', value: '3' },
        { label: '🍺', value: '4' },
      ],
    }
  },
  valueFormatter: async (val, instance) => {
    // Here we ask the current instance to build the value which
    // would have been displayed if we didn't overload valueFormatter.
    // It uses the type to build a readable value, uses the one from
    // the current editing session if any or builds one on the fly otherwise
    const readableValue = await instance.buildStandardReadableValue(val);
    return `Today I'm feeling ${readableValue}`;
  }
});
Using HTML attributes based configuration

Note that some configuration value can expect various format such as json, number or boolean. In these cases you can add a modifier to the configuration value:

For example: data-fcnf-renderer-config-popper_config:json='{"placement":"bottom"}'

Edit me
Edit me too!
<div class="flyter-attr" data-fcnf-initial_value="Edit me">Edit me</div>

<div class="flyter-attr"
  data-fcnf-type-name="text"
  data-fcnf-type-config-type="textarea"
  data-fcnf-initial_value="Edit me too!"
  data-fcnf-renderer-config-popper_config:json='{"placement":"bottom"}'>Edit me</div>
Attaching to buttons (or something else)

Flyter can be attached to any kind of element. It will append new children to it to work. This might cause problem, for example with buttons when triggering it, as the triggered element will not be the button but the span which flyter has appended to it. To handle it you can use the triggerOnTarget option.

flyter.attach('.flyter-btn', {
  triggerOnTarget: true, // will attach trigger to the target given during initialization
  renderer: {
    config: {
      popperConfig: {
        modifiers: [
          {
            name: 'offset',
            options: {
              offset: [50, 70], // offset to match this big bootstrap button
            }
          }
        ]
      }
    }
  }
});

License

Apache 2.0 License