These are chat archives for GetmeUK/ContentTools

15th
Oct 2015
Anthony Blackshaw
@anthonyjb
Oct 15 2015 00:14
Sorry - I should by very basic I mean CT supports plain/text pastes only
Benjamin Intal
@bfintal
Oct 15 2015 02:08
When I do MyElement.placements = ['left', 'right']; for dragging, the center placement still gets applied
Benjamin Intal
@bfintal
Oct 15 2015 02:28
I have a patch, but it entails checking the drop target:
ContentEdit.Root.get().__getDropPlacement = ContentEdit.Root.get()._getDropPlacement;
ContentEdit.Root.get()._getDropPlacement = function(x, y) {
  var ret = ContentEdit.Root.get().__getDropPlacement( x, y );

  if ( this._dropTarget.constructor.placements.indexOf('center') === -1 ) {
      var rect = this._dropTarget.domElement().getBoundingClientRect();
      if ( x - rect.left < rect.width / 2 ) {
          ret[1] = 'left';
      } else {
          ret[1] = 'right';
      }
  }

  return ret;
};
Not sure if this should be a PR because of the dropTarget checking
Anthony Blackshaw
@anthonyjb
Oct 15 2015 06:16
@bfintal - that's an interesting one - and I think this approach is fine - if you want to submit a PR for it that's great - I think there needs to be a test that there is a @_dropTarget otherwise this could fail.
I'm off on my travels for the weekend so might be Monday/Tuesday next week before I respond to any PR but it'll be priority once I'm back :)
Benjamin Intal
@bfintal
Oct 15 2015 08:25
// Allow columns to be ONLY drag & dropped horizontalls across other columns
ContentEdit.Root.get().__getDropPlacement = ContentEdit.Root.get()._getDropPlacement;
ContentEdit.Root.get()._getDropPlacement = function(x, y) {
  var ret = ContentEdit.Root.get().__getDropPlacement( x, y );

  if ( this._dropTarget === null ) {
      return ret;
  }
  if ( this._dropTarget.constructor === null ) {
      return ret;
  }

  if ( this._dropTarget.constructor.name === 'DivCol' ) {
      if ( this._dropTarget.constructor.placements.indexOf('center') === -1 ) {
          var rect = this._dropTarget.domElement().getBoundingClientRect();
          if ( x - rect.left < rect.width / 2 ) {
              ret[1] = 'left';
          } else {
              ret[1] = 'right';
          }
      }
  }

  return ret;
};
The only problem I have is that I'm doing everything in pure js haha!
Benjamin Intal
@bfintal
Oct 15 2015 09:39
I'm encountering something weird
Sometimes after doing some edits and changing browser tabs.. when I go back to the editing tab, the whole editable area sometimes gets an orange outline as if it's highlighted then the outline blinks and blinks and the page becomes slow to respond. Since I was previously editing, I can hit the okay or cancel button, and the flickering outline is still there. No console errors.