0.1.2 • Published 8 years ago

selection-update v0.1.2

Weekly downloads
9,596
License
MIT
Repository
github
Last release
8 years ago

selection-update

Build Status

Computing input selection updates on external file changes, as if we used browser managed undo and redo.

API

/**
 * Calculate the selection update for the given
 * current and new input values.
 *
 * @param {Object} currentSelection as {start, end}
 * @param {String} currentValue
 * @param {String} newValue
 *
 * @return {Object} newSelection as {start, end}
 */
calculateUpdate(currentSelection, currentValue, newValue);

Usage

var selectionUpdate = require('selection-update');

/**
 * Update input with new value.

 * @param {Node} $input
 * @param {String} newValue
 */
function updateInput($input, newValue) {

  var newSelection;

  // only retrieve and restore input, if the element
  // is currently active
  if (document.activeElement === $input) {

    // get the current selection and pass it in as {start, end}
    newSelection = selectionUpdate(getSelection($input), $input.value, newValue);
  }

  // apply new value, will naturally send selection to input end
  $input.value = value;

  if (newSelection) {
    // set new {start, end} selection on input
    setSelection($input, selection);
  }
}

License

MIT

properties-panel-user-taskvue-bpmn-designer@infinitebrahmanuniverse/nolb-sele@everything-registry/sub-chunk-2728jp-bpmn-js-properties-panelkaka-bpmn-js-properties-panelnanjids-bpmn-panelphzjhbasicnisieosmy-bpmn-properties-paneltechforce-bpmn-js-properties-paneltechforceai-bpmn-js-properties-paneltf-bpmn-js-properties-panelshidl021-bjppsedsuscipitrunbpm-js-properties-panelwom-bpmn-properties-panelais-bpmn-js-properties-panel@quarks/bpmn-js-properties-panelapmn-js-properties-panel@6dtech/6d-bpmn-js-properties-panelbdframe-workflowcms-finance-uicms-fronted-uicmmn-js-properties-panelenimrecusandaeey-activiti-designerhi-smart-bpmn-js-properties-panelbpm-micro-bpmn-js-properties-panelbpmn-aranibpmn-domino-properties-panelbpmn-vue-middolbpmn2020bpmn-js-properties-panel-activitibpmn-js-properties-panel-activiti-supportbpmn-js-properties-panel-cnbpmn-js-properties-panel-dz6bpmn-js-properties-panel-for-activitibpmn-js-properties-panel-for-huabibpmn-js-properties-panel-jlbpmn-js-properties-panel-keeleybpmn-js-properties-panel-lswbpmn-js-properties-panel-lzhbpmn-js-properties-panel-select-userbpmn-js-properties-panel-sybpmn-js-jl-properties-panelbpmn-panel-extendbpmn-js-panelbpmn-js-panel-activiti@dogtiti/dmn-js-sharedcasemanagement-js-properties-panelepx-bpmn-js-properties-panelcus-bpmn-js-properties-panelfugiatcorruptiflyme-flow-designifml-jshoutaroy-bpmn-js-properties-panel-activiticustom-properties-panelgengen-bpmn-panel-activitijc-bpmn-js-properties-panel-activitijc-serve-bpmn-js-properties-panel-activitijc-server-bpmn-js-properties-panel-activitidmn-js-shared
0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago