@textbus/platform-browser 4.0.0-alpha.13 → 4.0.0-alpha.16

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.
@@ -375,26 +375,7 @@ class DomAdapter extends ViewAdapter {
375
375
  return [];
376
376
  }
377
377
  const rootVNode = this.slotRootVElementCaches.get(slot);
378
- const getNodes = (vElement, nativeNode, result) => {
379
- if (vElement.location) {
380
- result.push(nativeNode);
381
- }
382
- for (let i = 0; i < vElement.children.length; i++) {
383
- const vChild = vElement.children[i];
384
- const nativeChild = nativeNode.childNodes[i];
385
- if (vChild instanceof VElement) {
386
- getNodes(vChild, nativeChild, result);
387
- }
388
- else if (vChild instanceof VTextNode) {
389
- result.push(nativeChild);
390
- }
391
- else {
392
- result.push(this.getNativeNodeByComponent(vChild));
393
- }
394
- }
395
- return result;
396
- };
397
- return getNodes(rootVNode, rootNativeNode, []);
378
+ return getNodes(this, rootVNode, rootNativeNode, []);
398
379
  }
399
380
  /**
400
381
  * 获取原生节点的原始数据在文档中的位置
@@ -410,40 +391,59 @@ class DomAdapter extends ViewAdapter {
410
391
  }
411
392
  const slot = this.slotRootNativeElementCaches.get(slotRootNode);
412
393
  const rootVNode = this.slotRootVElementCaches.get(slot);
413
- const getLocation = (target, tree, vNodeTree) => {
414
- if (target === tree) {
415
- return Object.assign({}, vNodeTree.location);
416
- }
417
- const childNodes = tree.childNodes;
418
- for (let i = 0; i < childNodes.length; i++) {
419
- const child = vNodeTree.children[i];
420
- const nativeChild = tree.childNodes[i];
421
- if (nativeChild === target) {
422
- if (child instanceof ComponentInstance) {
423
- const index = child.parent.indexOf(child);
424
- return {
425
- slot: child.parent,
426
- startIndex: index,
427
- endIndex: index + 1
428
- };
429
- }
430
- return child.location;
431
- }
432
- else if (child instanceof VElement) {
433
- let r = null;
434
- if (nativeChild.nodeType === Node.ELEMENT_NODE) {
435
- r = getLocation(target, nativeChild, child);
436
- }
437
- if (r) {
438
- return r;
439
- }
440
- }
441
- }
442
- return null;
443
- };
444
394
  return getLocation(node, slotRootNode, rootVNode);
445
395
  }
446
396
  }
397
+ function getNodes(adapter, vElement, nativeNode, result) {
398
+ if (vElement.location) {
399
+ result.push(nativeNode);
400
+ }
401
+ for (let i = 0; i < vElement.children.length; i++) {
402
+ const vChild = vElement.children[i];
403
+ const nativeChild = nativeNode.childNodes[i];
404
+ if (vChild instanceof VElement) {
405
+ getNodes(adapter, vChild, nativeChild, result);
406
+ }
407
+ else if (vChild instanceof VTextNode) {
408
+ result.push(nativeChild);
409
+ }
410
+ else {
411
+ result.push(adapter.getNativeNodeByComponent(vChild));
412
+ }
413
+ }
414
+ return result;
415
+ }
416
+ function getLocation(target, tree, vNodeTree) {
417
+ if (target === tree) {
418
+ return Object.assign({}, vNodeTree.location);
419
+ }
420
+ const childNodes = tree.childNodes;
421
+ for (let i = 0; i < childNodes.length; i++) {
422
+ const child = vNodeTree.children[i];
423
+ const nativeChild = tree.childNodes[i];
424
+ if (nativeChild === target) {
425
+ if (child instanceof ComponentInstance) {
426
+ const index = child.parent.indexOf(child);
427
+ return {
428
+ slot: child.parent,
429
+ startIndex: index,
430
+ endIndex: index + 1
431
+ };
432
+ }
433
+ return child.location;
434
+ }
435
+ else if (child instanceof VElement) {
436
+ let r = null;
437
+ if (nativeChild.nodeType === Node.ELEMENT_NODE) {
438
+ r = getLocation(target, nativeChild, child);
439
+ }
440
+ if (r) {
441
+ return r;
442
+ }
443
+ }
444
+ }
445
+ return null;
446
+ }
447
447
 
448
448
  /**
449
449
  * Textbus PC 端选区桥接实现
@@ -2041,8 +2041,8 @@ let NativeInput = class NativeInput extends Input {
2041
2041
  });
2042
2042
  }));
2043
2043
  }
2044
- handlePaste(html, text) {
2045
- const slot = this.parser.parse(html, new Slot([
2044
+ handlePaste(dom, text) {
2045
+ const slot = this.parser.parse(dom, new Slot([
2046
2046
  ContentType.BlockComponent,
2047
2047
  ContentType.InlineComponent,
2048
2048
  ContentType.Text
package/bundles/index.js CHANGED
@@ -377,26 +377,7 @@ class DomAdapter extends core$1.ViewAdapter {
377
377
  return [];
378
378
  }
379
379
  const rootVNode = this.slotRootVElementCaches.get(slot);
380
- const getNodes = (vElement, nativeNode, result) => {
381
- if (vElement.location) {
382
- result.push(nativeNode);
383
- }
384
- for (let i = 0; i < vElement.children.length; i++) {
385
- const vChild = vElement.children[i];
386
- const nativeChild = nativeNode.childNodes[i];
387
- if (vChild instanceof core$1.VElement) {
388
- getNodes(vChild, nativeChild, result);
389
- }
390
- else if (vChild instanceof core$1.VTextNode) {
391
- result.push(nativeChild);
392
- }
393
- else {
394
- result.push(this.getNativeNodeByComponent(vChild));
395
- }
396
- }
397
- return result;
398
- };
399
- return getNodes(rootVNode, rootNativeNode, []);
380
+ return getNodes(this, rootVNode, rootNativeNode, []);
400
381
  }
401
382
  /**
402
383
  * 获取原生节点的原始数据在文档中的位置
@@ -412,40 +393,59 @@ class DomAdapter extends core$1.ViewAdapter {
412
393
  }
413
394
  const slot = this.slotRootNativeElementCaches.get(slotRootNode);
414
395
  const rootVNode = this.slotRootVElementCaches.get(slot);
415
- const getLocation = (target, tree, vNodeTree) => {
416
- if (target === tree) {
417
- return Object.assign({}, vNodeTree.location);
418
- }
419
- const childNodes = tree.childNodes;
420
- for (let i = 0; i < childNodes.length; i++) {
421
- const child = vNodeTree.children[i];
422
- const nativeChild = tree.childNodes[i];
423
- if (nativeChild === target) {
424
- if (child instanceof core$1.ComponentInstance) {
425
- const index = child.parent.indexOf(child);
426
- return {
427
- slot: child.parent,
428
- startIndex: index,
429
- endIndex: index + 1
430
- };
431
- }
432
- return child.location;
433
- }
434
- else if (child instanceof core$1.VElement) {
435
- let r = null;
436
- if (nativeChild.nodeType === Node.ELEMENT_NODE) {
437
- r = getLocation(target, nativeChild, child);
438
- }
439
- if (r) {
440
- return r;
441
- }
442
- }
443
- }
444
- return null;
445
- };
446
396
  return getLocation(node, slotRootNode, rootVNode);
447
397
  }
448
398
  }
399
+ function getNodes(adapter, vElement, nativeNode, result) {
400
+ if (vElement.location) {
401
+ result.push(nativeNode);
402
+ }
403
+ for (let i = 0; i < vElement.children.length; i++) {
404
+ const vChild = vElement.children[i];
405
+ const nativeChild = nativeNode.childNodes[i];
406
+ if (vChild instanceof core$1.VElement) {
407
+ getNodes(adapter, vChild, nativeChild, result);
408
+ }
409
+ else if (vChild instanceof core$1.VTextNode) {
410
+ result.push(nativeChild);
411
+ }
412
+ else {
413
+ result.push(adapter.getNativeNodeByComponent(vChild));
414
+ }
415
+ }
416
+ return result;
417
+ }
418
+ function getLocation(target, tree, vNodeTree) {
419
+ if (target === tree) {
420
+ return Object.assign({}, vNodeTree.location);
421
+ }
422
+ const childNodes = tree.childNodes;
423
+ for (let i = 0; i < childNodes.length; i++) {
424
+ const child = vNodeTree.children[i];
425
+ const nativeChild = tree.childNodes[i];
426
+ if (nativeChild === target) {
427
+ if (child instanceof core$1.ComponentInstance) {
428
+ const index = child.parent.indexOf(child);
429
+ return {
430
+ slot: child.parent,
431
+ startIndex: index,
432
+ endIndex: index + 1
433
+ };
434
+ }
435
+ return child.location;
436
+ }
437
+ else if (child instanceof core$1.VElement) {
438
+ let r = null;
439
+ if (nativeChild.nodeType === Node.ELEMENT_NODE) {
440
+ r = getLocation(target, nativeChild, child);
441
+ }
442
+ if (r) {
443
+ return r;
444
+ }
445
+ }
446
+ }
447
+ return null;
448
+ }
449
449
 
450
450
  /**
451
451
  * Textbus PC 端选区桥接实现
@@ -2043,8 +2043,8 @@ let NativeInput = class NativeInput extends Input {
2043
2043
  });
2044
2044
  }));
2045
2045
  }
2046
- handlePaste(html, text) {
2047
- const slot = this.parser.parse(html, new core$1.Slot([
2046
+ handlePaste(dom, text) {
2047
+ const slot = this.parser.parse(dom, new core$1.Slot([
2048
2048
  core$1.ContentType.BlockComponent,
2049
2049
  core$1.ContentType.InlineComponent,
2050
2050
  core$1.ContentType.Text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.13",
3
+ "version": "4.0.0-alpha.16",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.0",
29
- "@textbus/core": "^4.0.0-alpha.13",
29
+ "@textbus/core": "^4.0.0-alpha.16",
30
30
  "@viewfly/core": "^0.3.0",
31
31
  "reflect-metadata": "^0.1.13"
32
32
  },
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "625efd792f5cc6d8008cdb007b4fe2adf6701189"
51
+ "gitHead": "374400df65cd485113048cd9644ae88f4ff59429"
52
52
  }