@use-kona/editor 0.1.24-dnd.3 → 0.1.24-dnd.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,10 +46,10 @@ class DnDPlugin {
46
46
  const isReadOnly = useReadOnly();
47
47
  const [dropPosition, setDropPosition] = useState(null);
48
48
  const dropTargetRef = useRef(null);
49
- options.customTypes?.[props.element.type];
49
+ const customType = options.customTypes?.[props.element.type];
50
50
  const currentElement = props.element;
51
51
  const [, drag, preview] = useDrag({
52
- type: DnDPlugin.DND_BLOCK_ELEMENT,
52
+ type: customType?.type || DnDPlugin.DND_BLOCK_ELEMENT,
53
53
  item: ()=>{
54
54
  const selected = Array.from($store.selected.values());
55
55
  const nodes = selected.length > 0 && selected.includes(currentElement.nodeId) ? getNodesByNodeIds(editor, selected) : [
@@ -104,18 +104,12 @@ class DnDPlugin {
104
104
  if (!sourceTo) return;
105
105
  const insertAt = getDropPath(editor, sourceTo, dropPosition || 'bottom');
106
106
  if (!insertAt) return;
107
- const customDropHandler = itemType && this.options.customDropHandlers?.[itemType];
108
- if (customDropHandler) {
109
- console.log('customDropHandler.onDrop', itemType);
110
- customDropHandler.onDrop({
111
- editor,
112
- item,
113
- insertAt
114
- });
115
- return;
116
- }
117
- console.log('customDropHandler not found', itemType);
118
- this.options.customDropHandlers && console.log('valid drop handlers are', Object.keys(this.options.customDropHandlers));
107
+ const customDropHandler = itemType && options.customDropHandlers?.[itemType];
108
+ if (customDropHandler) return void customDropHandler.onDrop({
109
+ editor,
110
+ item,
111
+ insertAt
112
+ });
119
113
  switch(itemType){
120
114
  case NativeTypes.FILE:
121
115
  options.onDropFiles(editor, item.files, insertAt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@use-kona/editor",
3
- "version": "0.1.24-dnd.3",
3
+ "version": "0.1.24-dnd.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -76,7 +76,7 @@ export class DnDPlugin implements IPlugin {
76
76
  const currentElement = props.element as NodeWithId;
77
77
 
78
78
  const [, drag, preview] = useDrag({
79
- type: DnDPlugin.DND_BLOCK_ELEMENT,
79
+ type: customType?.type || DnDPlugin.DND_BLOCK_ELEMENT,
80
80
  item: () => {
81
81
  const selected = Array.from($store.selected.values());
82
82
 
@@ -167,19 +167,11 @@ export class DnDPlugin implements IPlugin {
167
167
  if (!insertAt) return;
168
168
 
169
169
  const customDropHandler =
170
- itemType && this.options.customDropHandlers?.[itemType];
170
+ itemType && options.customDropHandlers?.[itemType];
171
171
 
172
172
  if (customDropHandler) {
173
- console.log('customDropHandler.onDrop', itemType);
174
173
  customDropHandler.onDrop({ editor, item, insertAt });
175
174
  return;
176
- } else {
177
- console.log('customDropHandler not found', itemType);
178
- this.options.customDropHandlers &&
179
- console.log(
180
- 'valid drop handlers are',
181
- Object.keys(this.options.customDropHandlers),
182
- );
183
175
  }
184
176
 
185
177
  switch (itemType) {