essentially, the idea here is that we're gonna find the currently instantiated L.Edit handler, figure out its type, get rid of it, and then replace it with a snapedit instead
6991
function(e) {
        L.EditToolbar.Edit.prototype._enableLayerEdit.call(this, e);

        var layer = e.layer || e.target || e;

        if (!layer.snapediting) {
            if (layer.hasOwnProperty('_mRadius')) {
                if (layer.editing) {
                    layer.editing._markerGroup.clearLayers();
                    delete layer.editing;
                }
                layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
            }
            
            else if (layer.getLatLng) {
                layer.snapediting = new L.Handler.MarkerSnap(layer._map, layer, this.snapOptions);
            }
            
            else {
                if (layer.editing) {
                    if (layer.editing.hasOwnProperty('_shape')) {
                        layer.editing._markerGroup.clearLayers();
                        if (layer.editing._shape instanceof L.Rectangle) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.RectangleSnap(layer._map, layer, this.snapOptions);
                        }
                        else if (layer.editing._shape instanceof L.FeatureGroup) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.FeatureGroupSnap(layer._map, layer, this.snapOptions);
                        }
                        else {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
                        }
                    }
                    else {
                        layer.editing._markerGroup.clearLayers();
                        layer.editing._verticesHandlers[0]._markerGroup.clearLayers();
                        delete layer.editing;
                        layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                    }
                }
                else {
                    layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                }
            }

            for (var i = 0, n = this._guideLayers.length; i < n; i++) {
                layer.snapediting.addGuideLayer(this._guideLayers[i]);
            }
        }

        layer.snapediting.enable();
    }
1655
private static void removeDirective(
            String elementId, String attributeName, String type, IPerson person) {
        Document plf = (Document) person.getAttribute(Constants.PLF);
        Element node = plf.getElementById(elementId);
        if (node == null) return;

        Element editSet = null;

        try {
            editSet = getEditSet(node, plf, person, false);
        } catch (Exception e) {
            /*
             * we should never get here since we are calling getEditSet passing
             * create=false meaning that the only portion of that method that
             * tosses an exception will not be reached with this call. But if a
             * runtime exception somehow occurs we will log it so that we don't
             * lose the information.
             */
            LOG.error(e, e);
            return;
        }

        // if no edit set then the edit can't be there either
        if (editSet == null) return;

        Node child = editSet.getFirstChild();

        while (child != null) {
            if (child.getNodeName().equals(type)) {
                Attr attr = ((Element) child).getAttributeNode(Constants.ATT_NAME);
                if (attr != null && attr.getValue().equals(attributeName)) {
                    // we found it, remove it
                    editSet.removeChild(child);
                    break;
                }
            }
            child = child.getNextSibling();
        }
        // if that was the last on in the edit set then delete it
        if (editSet.getFirstChild() == null) node.removeChild(editSet);
    }
857792
function handleEditorChange(session, document, previousDocument) {

        if (!currentModule) {
            currentModule = new TernModule();
        }
        
        return currentModule.handleEditorChange(session, document, previousDocument);
    }
1265436
function editorUpdate() {
    if (editor.binding) {
      if ('hold' === generator.clientUpdateFragmentText(editor.binding, editor.$edit.val())) {
        editor.holding = true;
      }
    }
  }
1322118
function snapSelected(sel) {
	sel = sel || getSelection();
	if (isCollapsed(sel)) { return; }

	var end = sel.focusNode;
	var off = sel.focusOffset;
	var dir = ['forward', 'backward'];
	isBackwards(sel) && dir.reverse();

	// modify() works on the focus of the selection
	sel.collapse(sel.anchorNode, sel.anchorOffset);

	sel.modify('move', dir[0], 'character');
	sel.modify('move', dir[1], 'word');
	sel.extend(end, off);
	sel.modify('extend', dir[1], 'character');
	sel.modify('extend', dir[0], 'word');
}
61805
function emptyEditorOnDeleteEverything() {
        function isEverythingSelected(editor) {
          var caretWalker = new CaretWalker(editor.getBody());
          var rng = editor.selection.getRng();
          var startCaretPos = CaretPosition.fromRangeStart(rng);
          var endCaretPos = CaretPosition.fromRangeEnd(rng);
          var prev = caretWalker.prev(startCaretPos);
          var next = caretWalker.next(endCaretPos);

          return !editor.selection.isCollapsed() &&
            (!prev || (prev.isAtStart() && startCaretPos.isEqual(prev))) &&
            (!next || (next.isAtEnd() && startCaretPos.isEqual(next)));
        }

        // Type over case delete and insert this won't cover typeover with a IME but at least it covers the common case
        editor.on('keypress', function (e) {
          if (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {
            if (isEverythingSelected(editor)) {
              e.preventDefault();
              editor.setContent(String.fromCharCode(e.charCode));
              editor.selection.select(editor.getBody(), true);
              editor.selection.collapse(false);
              editor.nodeChanged();
            }
          }
        });

        editor.on('keydown', function (e) {
          var keyCode = e.keyCode;

          if (!isDefaultPrevented(e) && (keyCode == DELETE || keyCode == BACKSPACE)) {
            if (isEverythingSelected(editor)) {
              e.preventDefault();
              editor.setContent('');
              editor.nodeChanged();
            }
          }
        });
      }
817336
function snap() {
            if (__snip < 0)
                throw(new Error("Illegal call to snap(): Not snipping"));
            var snipped = __out.splice(__snip, __out.length - __snip).join('');
            __snip = -1;
            return snipped;
        }
1248994
function() {
    if(this._oCellEditor) {
        if(this._oCellEditor.cancel) {
            this._oCellEditor.cancel();
        }
        // Backward compatibility
        else if(this._oCellEditor.isActive) {
            this.resetCellEditor();
            //TODO: preserve values for the event?
            this.fireEvent("editorCancelEvent", {editor:this._oCellEditor});
            YAHOO.log("Cell Editor input canceled", "info", this.toString());
        }

        YAHOO.log("CellEditor input canceled", "info", this.toString());
    }
}
1366571
function (type, handler) {

            // Validate arguments
            if (typeof type !== 'undefined' && typeof type !== 'string') {
                throw new Error('Type must be a string or undefined');
            }
            if (typeof handler !== 'undefined' && typeof handler !== 'function') {
                throw new Error('Handler must be a function or undefined');
            }

            // If no type is given, remove all handlers
            if (!type) {
                return delete this._events;
            }

            // Check for presence of event store
            if (!this._events || !this._events[type]) {
                return;
            }

            // If no handler is given, remove all handlers for this type
            if (!handler) {
                return delete this._events[type];
            }

            // Do we have a matching handler?
            var handlers = this._events[type];
            var i = arrayIndexOf(handlers, handler);
            if (i === -1) {
                return;
            }

            // Remove handler
            handlers.splice(i, 1);

        }
833053
function removeHandler(node, eventType, handler, thisObject){
    node = getNode(node);

    var handlers = node === global ? globalEvents : node[EVENT_HOLDER];
    if (handlers)
    {
      var eventTypeHandlers = handlers[eventType];
      if (eventTypeHandlers)
      {
        for (var i = 0, item; item = eventTypeHandlers[i]; i++)
        {
          if (item.handler === handler && item.thisObject === thisObject)
          {
            // delete event handler
            eventTypeHandlers.splice(i, 1);

            // if there is no more handler for this event, clear it
            if (!eventTypeHandlers.length)
              clearHandlers(node, eventType);

            return;
          }
        }
      }
    }
  }
248840
function() {
      var t = this,
          val = t.editor.val();
      if (val) {
       try {
          // Throw away parse errors while typing
          t.model.set(JSON.parse(val));
        } catch (e) {
          return false;
        }
      } else {
        // Confirm deletion if user removes everything in the JSON window
        if (t.deletePage()) {
         return false;
        } else {
          // Reset source data
          t.fillSourceData();
        }
      }
      return true;
    }
13451
function onEnter(
    event: *,
    change: Change,
    editor: *,
    opts: Options
): void | any {
    // Pressing Shift+Enter
    // should split block normally
    if (event.shiftKey) {
        return undefined;
    }

    const { value } = change;
    const currentItem = getCurrentItem(opts, value);

    // Not in a list
    if (!currentItem) {
        return undefined;
    }

    event.preventDefault();

    // If expanded, delete first.
    if (value.isExpanded) {
        change.delete();
    }

    if (currentItem.isEmpty) {
        // Block is empty, we exit the list
        if (getItemDepth(opts, value) > 1) {
            return decreaseItemDepth(opts, change);
        }
        // Exit list
        return unwrapList(opts, change);
    }
    // Split list item
    return splitListItem(opts, change);
}
161709
function(type, handler) {
      if (!this.listeners_)
        return;
      if (type in this.listeners_) {
        var handlers = this.listeners_[type];
        var index = handlers.indexOf(handler);
        if (index >= 0) {
          // Clean up if this was the last listener.
          if (handlers.length == 1)
            delete this.listeners_[type];
          else
            handlers.splice(index, 1);
        }
      }
    }
956177
function( editor )
		{
			var hr = editor.document.createElement( 'hr' ),
				range = new CKEDITOR.dom.range( editor.document );

			editor.insertElement( hr );

			// If there's nothing or a non-editable block followed by, establish a new paragraph
			// to make sure cursor is not trapped.
			range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END );
			var next = hr.getNext();
			if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() )
				range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p'  );

			range.select();
		}
1121519
function fixCut() {
			if ( !CKEDITOR.env.ie || CKEDITOR.env.quirks )
				return;

			var sel = editor.getSelection(),
				control, range, dummy;

			if ( ( sel.getType() == CKEDITOR.SELECTION_ELEMENT ) && ( control = sel.getSelectedElement() ) ) {
				range = sel.getRanges()[ 0 ];
				dummy = editor.document.createText( '' );
				dummy.insertBefore( control );
				range.setStartBefore( dummy );
				range.setEndAfter( control );
				sel.selectRanges( [ range ] );

				// Clear up the fix if the paste wasn't succeeded.
				setTimeout( function() {
					// Element still online?
					if ( control.getParent() ) {
						dummy.remove();
						sel.selectElement( control );
					}
				}, 0 );
			}
		}
971322
function handleHardNewlineEvent(editorState: EditorState): EditorState {
  const selection = editorState.getSelection();
  if (selection.isCollapsed()) {
    const contentState = editorState.getCurrentContent();
    const blockKey = selection.getStartKey();
    const block = contentState.getBlockForKey(blockKey);
    if (
      !isListBlock(block) &&
      block.getType() !== 'unstyled' &&
      block.getLength() === selection.getStartOffset()
    ) {
      return insertNewUnstyledBlock(editorState);
    } else if (isListBlock(block) && block.getLength() === 0) {
      const depth = block.getDepth();
      if (depth === 0) {
        return removeSelectedBlocksStyle(editorState);
      }
      if (depth > 0) {
        return changeListDepth(editorState, -1, depth);
      }
    }
  }
  return undefined;
}
501677
function _restoreEditorViewState(editor) {
        // We want to ignore the current state of the editor, so don't call __getViewState()
        var viewState = ViewStateManager.getViewState(editor.document.file);
        if (viewState) {
            editor.restoreViewState(viewState);
        }
    }