@textbus/xnote 0.0.1-alpha.7 → 0.0.1-alpha.8

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.
@@ -901,7 +901,7 @@ class SourceCodeComponent extends Component {
901
901
  },
902
902
  action() {
903
903
  if (selection.isCollapsed) {
904
- commander.insert(' ');
904
+ commander.insert(' ');
905
905
  return;
906
906
  }
907
907
  const blocks = selection.getBlocks();
@@ -1458,8 +1458,6 @@ class TableComponent extends Component {
1458
1458
  rowspan: 1,
1459
1459
  colspan: 1,
1460
1460
  slot: new Slot([
1461
- ContentType.Text,
1462
- ContentType.InlineComponent,
1463
1461
  ContentType.BlockComponent
1464
1462
  ])
1465
1463
  };
@@ -1541,8 +1539,6 @@ class TableComponent extends Component {
1541
1539
  this.state.rows.forEach(row => {
1542
1540
  const slot = new Slot([
1543
1541
  ContentType.BlockComponent,
1544
- ContentType.InlineComponent,
1545
- ContentType.Text
1546
1542
  ]);
1547
1543
  slot.insert(new ParagraphComponent(this.textbus, {
1548
1544
  slot: new Slot([
@@ -1570,8 +1566,6 @@ class TableComponent extends Component {
1570
1566
  cells: this.state.layoutWidth.map(() => {
1571
1567
  const slot = new Slot([
1572
1568
  ContentType.BlockComponent,
1573
- ContentType.InlineComponent,
1574
- ContentType.Text
1575
1569
  ]);
1576
1570
  slot.insert(new ParagraphComponent(this.textbus, {
1577
1571
  slot: new Slot([
@@ -1779,8 +1773,6 @@ class BlockquoteComponent extends Component {
1779
1773
  }
1780
1774
  constructor(textbus, state = {
1781
1775
  slot: new Slot([
1782
- ContentType.Text,
1783
- ContentType.InlineComponent,
1784
1776
  ContentType.BlockComponent
1785
1777
  ])
1786
1778
  }) {
@@ -1798,8 +1790,6 @@ BlockquoteComponent.zenCoding = {
1798
1790
  createState() {
1799
1791
  return {
1800
1792
  slot: new Slot([
1801
- ContentType.Text,
1802
- ContentType.InlineComponent,
1803
1793
  ContentType.BlockComponent
1804
1794
  ])
1805
1795
  };
@@ -1822,14 +1812,10 @@ const blockquoteComponentLoader = {
1822
1812
  },
1823
1813
  read(element, textbus, slotParser) {
1824
1814
  const delta = slotParser(new Slot([
1825
- ContentType.Text,
1826
1815
  ContentType.BlockComponent,
1827
- ContentType.InlineComponent
1828
1816
  ]), element).toDelta();
1829
1817
  const slot = new Slot([
1830
1818
  ContentType.BlockComponent,
1831
- ContentType.InlineComponent,
1832
- ContentType.Text
1833
1819
  ]);
1834
1820
  deltaToBlock(delta, textbus).forEach(i => {
1835
1821
  slot.insert(i);
@@ -2159,8 +2145,6 @@ class HighlightBoxComponent extends Component {
2159
2145
  type: '',
2160
2146
  slot: new Slot([
2161
2147
  ContentType.BlockComponent,
2162
- ContentType.InlineComponent,
2163
- ContentType.Text
2164
2148
  ])
2165
2149
  }) {
2166
2150
  super(textbus, state);
@@ -2214,13 +2198,9 @@ const highlightBoxComponentLoader = {
2214
2198
  read(element, textbus, slotParser) {
2215
2199
  const delta = slotParser(new Slot([
2216
2200
  ContentType.BlockComponent,
2217
- ContentType.InlineComponent,
2218
- ContentType.Text
2219
2201
  ]), element.querySelector('.xnote-highlight-box-content')).toDelta();
2220
2202
  const slot = new Slot([
2221
2203
  ContentType.BlockComponent,
2222
- ContentType.InlineComponent,
2223
- ContentType.Text
2224
2204
  ]);
2225
2205
  deltaToBlock(delta, textbus).forEach(i => {
2226
2206
  slot.insert(i);
@@ -3934,45 +3914,17 @@ class RootComponent extends Component {
3934
3914
  this.onCompositionStart = new Subject();
3935
3915
  }
3936
3916
  static fromJSON(textbus, json) {
3937
- // const heading = textbus.get(Registry).createSlot(json.heading)
3938
3917
  const content = textbus.get(Registry).createSlot(json.content);
3939
3918
  return new RootComponent(textbus, {
3940
- // heading,
3941
3919
  content
3942
3920
  });
3943
3921
  }
3944
3922
  setup() {
3945
- // const textbus = useContext()
3946
- // const selection = textbus.get(Selection)
3947
- // onBreak(ev => {
3948
- // if (ev.target === this.state.heading) {
3949
- // const afterContent = ev.target.cut(ev.data.index)
3950
- // const p = new ParagraphComponent(textbus, {
3951
- // slot: afterContent
3952
- // })
3953
- // const body = this.state.content
3954
- // body.retain(0)
3955
- // body.insert(p)
3956
- // selection.setPosition(afterContent, 0)
3957
- // ev.preventDefault()
3958
- // }
3959
- // })
3960
3923
  useBlockContent(this.state.content);
3961
3924
  onCompositionStart(ev => {
3962
3925
  this.onCompositionStart.next(ev);
3963
3926
  });
3964
3927
  }
3965
- afterCheck() {
3966
- const content = this.state.content;
3967
- const lastContent = content.getContentAtIndex(content.length - 1);
3968
- if (lastContent instanceof ParagraphComponent ||
3969
- lastContent instanceof ListComponent ||
3970
- lastContent instanceof TodolistComponent) {
3971
- return;
3972
- }
3973
- content.retain(content.length);
3974
- content.insert(new ParagraphComponent(this.textbus));
3975
- }
3976
3928
  }
3977
3929
  RootComponent.componentName = 'RootComponent';
3978
3930
  RootComponent.type = ContentType.BlockComponent;
@@ -3987,9 +3939,6 @@ function RootView(props) {
3987
3939
  sub.unsubscribe();
3988
3940
  };
3989
3941
  });
3990
- // onUpdated(() => {
3991
- // props.component.afterCheck()
3992
- // })
3993
3942
  const readonly = useReadonly();
3994
3943
  const output = useOutput();
3995
3944
  return () => {
@@ -4658,8 +4607,6 @@ const tableComponentLoader = {
4658
4607
  Array.from(row.cells).forEach(cell => {
4659
4608
  const slot = new Slot([
4660
4609
  ContentType.BlockComponent,
4661
- ContentType.InlineComponent,
4662
- ContentType.Text
4663
4610
  ]);
4664
4611
  arr.push({
4665
4612
  slot,
@@ -4668,8 +4615,6 @@ const tableComponentLoader = {
4668
4615
  });
4669
4616
  const delta = slotParser(new Slot([
4670
4617
  ContentType.BlockComponent,
4671
- ContentType.InlineComponent,
4672
- ContentType.Text
4673
4618
  ]), cell).toDelta();
4674
4619
  const results = deltaToBlock(delta, textbus);
4675
4620
  results.forEach(i => {
@@ -4687,8 +4632,6 @@ const tableComponentLoader = {
4687
4632
  Array.from(row.cells).forEach(cell => {
4688
4633
  const slot = new Slot([
4689
4634
  ContentType.BlockComponent,
4690
- ContentType.InlineComponent,
4691
- ContentType.Text
4692
4635
  ]);
4693
4636
  arr.push({
4694
4637
  slot,
@@ -4697,8 +4640,6 @@ const tableComponentLoader = {
4697
4640
  });
4698
4641
  const delta = slotParser(new Slot([
4699
4642
  ContentType.BlockComponent,
4700
- ContentType.InlineComponent,
4701
- ContentType.Text
4702
4643
  ]), cell).toDelta();
4703
4644
  const results = deltaToBlock(delta, textbus);
4704
4645
  results.forEach(i => {
@@ -4775,8 +4716,6 @@ function autoComplete(table) {
4775
4716
  rowspan: 1,
4776
4717
  colspan: 1,
4777
4718
  slot: new Slot([
4778
- ContentType.Text,
4779
- ContentType.InlineComponent,
4780
4719
  ContentType.BlockComponent
4781
4720
  ])
4782
4721
  };
@@ -4933,14 +4872,12 @@ class Editor extends Textbus {
4933
4872
  const parser = this.get(Parser);
4934
4873
  const doc = parser.parseDoc(config.content, rootComponentLoader);
4935
4874
  rootComp = doc instanceof Component ? doc : new RootComponent(this, {
4936
- // heading: new Slot([ContentType.Text]),
4937
4875
  content: doc
4938
4876
  });
4939
4877
  }
4940
4878
  else {
4941
4879
  rootComp = new RootComponent(this, {
4942
- // heading: new Slot([ContentType.Text]),
4943
- content: new Slot([ContentType.Text, ContentType.InlineComponent, ContentType.BlockComponent])
4880
+ content: new Slot([ContentType.BlockComponent])
4944
4881
  });
4945
4882
  }
4946
4883
  return this.render(rootComp);
package/bundles/index.js CHANGED
@@ -903,7 +903,7 @@ class SourceCodeComponent extends core$1.Component {
903
903
  },
904
904
  action() {
905
905
  if (selection.isCollapsed) {
906
- commander.insert(' ');
906
+ commander.insert(' ');
907
907
  return;
908
908
  }
909
909
  const blocks = selection.getBlocks();
@@ -1460,8 +1460,6 @@ class TableComponent extends core$1.Component {
1460
1460
  rowspan: 1,
1461
1461
  colspan: 1,
1462
1462
  slot: new core$1.Slot([
1463
- core$1.ContentType.Text,
1464
- core$1.ContentType.InlineComponent,
1465
1463
  core$1.ContentType.BlockComponent
1466
1464
  ])
1467
1465
  };
@@ -1543,8 +1541,6 @@ class TableComponent extends core$1.Component {
1543
1541
  this.state.rows.forEach(row => {
1544
1542
  const slot = new core$1.Slot([
1545
1543
  core$1.ContentType.BlockComponent,
1546
- core$1.ContentType.InlineComponent,
1547
- core$1.ContentType.Text
1548
1544
  ]);
1549
1545
  slot.insert(new ParagraphComponent(this.textbus, {
1550
1546
  slot: new core$1.Slot([
@@ -1572,8 +1568,6 @@ class TableComponent extends core$1.Component {
1572
1568
  cells: this.state.layoutWidth.map(() => {
1573
1569
  const slot = new core$1.Slot([
1574
1570
  core$1.ContentType.BlockComponent,
1575
- core$1.ContentType.InlineComponent,
1576
- core$1.ContentType.Text
1577
1571
  ]);
1578
1572
  slot.insert(new ParagraphComponent(this.textbus, {
1579
1573
  slot: new core$1.Slot([
@@ -1781,8 +1775,6 @@ class BlockquoteComponent extends core$1.Component {
1781
1775
  }
1782
1776
  constructor(textbus, state = {
1783
1777
  slot: new core$1.Slot([
1784
- core$1.ContentType.Text,
1785
- core$1.ContentType.InlineComponent,
1786
1778
  core$1.ContentType.BlockComponent
1787
1779
  ])
1788
1780
  }) {
@@ -1800,8 +1792,6 @@ BlockquoteComponent.zenCoding = {
1800
1792
  createState() {
1801
1793
  return {
1802
1794
  slot: new core$1.Slot([
1803
- core$1.ContentType.Text,
1804
- core$1.ContentType.InlineComponent,
1805
1795
  core$1.ContentType.BlockComponent
1806
1796
  ])
1807
1797
  };
@@ -1824,14 +1814,10 @@ const blockquoteComponentLoader = {
1824
1814
  },
1825
1815
  read(element, textbus, slotParser) {
1826
1816
  const delta = slotParser(new core$1.Slot([
1827
- core$1.ContentType.Text,
1828
1817
  core$1.ContentType.BlockComponent,
1829
- core$1.ContentType.InlineComponent
1830
1818
  ]), element).toDelta();
1831
1819
  const slot = new core$1.Slot([
1832
1820
  core$1.ContentType.BlockComponent,
1833
- core$1.ContentType.InlineComponent,
1834
- core$1.ContentType.Text
1835
1821
  ]);
1836
1822
  deltaToBlock(delta, textbus).forEach(i => {
1837
1823
  slot.insert(i);
@@ -2161,8 +2147,6 @@ class HighlightBoxComponent extends core$1.Component {
2161
2147
  type: '',
2162
2148
  slot: new core$1.Slot([
2163
2149
  core$1.ContentType.BlockComponent,
2164
- core$1.ContentType.InlineComponent,
2165
- core$1.ContentType.Text
2166
2150
  ])
2167
2151
  }) {
2168
2152
  super(textbus, state);
@@ -2216,13 +2200,9 @@ const highlightBoxComponentLoader = {
2216
2200
  read(element, textbus, slotParser) {
2217
2201
  const delta = slotParser(new core$1.Slot([
2218
2202
  core$1.ContentType.BlockComponent,
2219
- core$1.ContentType.InlineComponent,
2220
- core$1.ContentType.Text
2221
2203
  ]), element.querySelector('.xnote-highlight-box-content')).toDelta();
2222
2204
  const slot = new core$1.Slot([
2223
2205
  core$1.ContentType.BlockComponent,
2224
- core$1.ContentType.InlineComponent,
2225
- core$1.ContentType.Text
2226
2206
  ]);
2227
2207
  deltaToBlock(delta, textbus).forEach(i => {
2228
2208
  slot.insert(i);
@@ -3936,45 +3916,17 @@ class RootComponent extends core$1.Component {
3936
3916
  this.onCompositionStart = new core$1.Subject();
3937
3917
  }
3938
3918
  static fromJSON(textbus, json) {
3939
- // const heading = textbus.get(Registry).createSlot(json.heading)
3940
3919
  const content = textbus.get(core$1.Registry).createSlot(json.content);
3941
3920
  return new RootComponent(textbus, {
3942
- // heading,
3943
3921
  content
3944
3922
  });
3945
3923
  }
3946
3924
  setup() {
3947
- // const textbus = useContext()
3948
- // const selection = textbus.get(Selection)
3949
- // onBreak(ev => {
3950
- // if (ev.target === this.state.heading) {
3951
- // const afterContent = ev.target.cut(ev.data.index)
3952
- // const p = new ParagraphComponent(textbus, {
3953
- // slot: afterContent
3954
- // })
3955
- // const body = this.state.content
3956
- // body.retain(0)
3957
- // body.insert(p)
3958
- // selection.setPosition(afterContent, 0)
3959
- // ev.preventDefault()
3960
- // }
3961
- // })
3962
3925
  useBlockContent(this.state.content);
3963
3926
  core$1.onCompositionStart(ev => {
3964
3927
  this.onCompositionStart.next(ev);
3965
3928
  });
3966
3929
  }
3967
- afterCheck() {
3968
- const content = this.state.content;
3969
- const lastContent = content.getContentAtIndex(content.length - 1);
3970
- if (lastContent instanceof ParagraphComponent ||
3971
- lastContent instanceof ListComponent ||
3972
- lastContent instanceof TodolistComponent) {
3973
- return;
3974
- }
3975
- content.retain(content.length);
3976
- content.insert(new ParagraphComponent(this.textbus));
3977
- }
3978
3930
  }
3979
3931
  RootComponent.componentName = 'RootComponent';
3980
3932
  RootComponent.type = core$1.ContentType.BlockComponent;
@@ -3989,9 +3941,6 @@ function RootView(props) {
3989
3941
  sub.unsubscribe();
3990
3942
  };
3991
3943
  });
3992
- // onUpdated(() => {
3993
- // props.component.afterCheck()
3994
- // })
3995
3944
  const readonly = useReadonly();
3996
3945
  const output = useOutput();
3997
3946
  return () => {
@@ -4660,8 +4609,6 @@ const tableComponentLoader = {
4660
4609
  Array.from(row.cells).forEach(cell => {
4661
4610
  const slot = new core$1.Slot([
4662
4611
  core$1.ContentType.BlockComponent,
4663
- core$1.ContentType.InlineComponent,
4664
- core$1.ContentType.Text
4665
4612
  ]);
4666
4613
  arr.push({
4667
4614
  slot,
@@ -4670,8 +4617,6 @@ const tableComponentLoader = {
4670
4617
  });
4671
4618
  const delta = slotParser(new core$1.Slot([
4672
4619
  core$1.ContentType.BlockComponent,
4673
- core$1.ContentType.InlineComponent,
4674
- core$1.ContentType.Text
4675
4620
  ]), cell).toDelta();
4676
4621
  const results = deltaToBlock(delta, textbus);
4677
4622
  results.forEach(i => {
@@ -4689,8 +4634,6 @@ const tableComponentLoader = {
4689
4634
  Array.from(row.cells).forEach(cell => {
4690
4635
  const slot = new core$1.Slot([
4691
4636
  core$1.ContentType.BlockComponent,
4692
- core$1.ContentType.InlineComponent,
4693
- core$1.ContentType.Text
4694
4637
  ]);
4695
4638
  arr.push({
4696
4639
  slot,
@@ -4699,8 +4642,6 @@ const tableComponentLoader = {
4699
4642
  });
4700
4643
  const delta = slotParser(new core$1.Slot([
4701
4644
  core$1.ContentType.BlockComponent,
4702
- core$1.ContentType.InlineComponent,
4703
- core$1.ContentType.Text
4704
4645
  ]), cell).toDelta();
4705
4646
  const results = deltaToBlock(delta, textbus);
4706
4647
  results.forEach(i => {
@@ -4777,8 +4718,6 @@ function autoComplete(table) {
4777
4718
  rowspan: 1,
4778
4719
  colspan: 1,
4779
4720
  slot: new core$1.Slot([
4780
- core$1.ContentType.Text,
4781
- core$1.ContentType.InlineComponent,
4782
4721
  core$1.ContentType.BlockComponent
4783
4722
  ])
4784
4723
  };
@@ -4935,14 +4874,12 @@ class Editor extends core$1.Textbus {
4935
4874
  const parser = this.get(platformBrowser.Parser);
4936
4875
  const doc = parser.parseDoc(config.content, rootComponentLoader);
4937
4876
  rootComp = doc instanceof core$1.Component ? doc : new RootComponent(this, {
4938
- // heading: new Slot([ContentType.Text]),
4939
4877
  content: doc
4940
4878
  });
4941
4879
  }
4942
4880
  else {
4943
4881
  rootComp = new RootComponent(this, {
4944
- // heading: new Slot([ContentType.Text]),
4945
- content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
4882
+ content: new core$1.Slot([core$1.ContentType.BlockComponent])
4946
4883
  });
4947
4884
  }
4948
4885
  return this.render(rootComp);
@@ -11,7 +11,6 @@ export declare class RootComponent extends Component<RootComponentState> {
11
11
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<RootComponentState>): RootComponent;
12
12
  onCompositionStart: Subject<Event<Slot, CompositionStartEventData>>;
13
13
  setup(): void;
14
- afterCheck(): void;
15
14
  }
16
15
  export declare function RootView(props: ViewComponentProps<RootComponent>): () => any;
17
16
  export declare const rootComponentLoader: ComponentLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.8",
4
4
  "description": "Viewfly project.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -14,10 +14,10 @@
14
14
  "test": "echo \"Error: no test specified\" && exit 1"
15
15
  },
16
16
  "dependencies": {
17
- "@textbus/adapter-viewfly": "^4.0.0-alpha.44",
18
- "@textbus/collaborate": "^4.0.0-alpha.44",
19
- "@textbus/core": "^4.0.0-alpha.44",
20
- "@textbus/platform-browser": "^4.0.0-alpha.44",
17
+ "@textbus/adapter-viewfly": "^4.0.0-alpha.45",
18
+ "@textbus/collaborate": "^4.0.0-alpha.45",
19
+ "@textbus/core": "^4.0.0-alpha.45",
20
+ "@textbus/platform-browser": "^4.0.0-alpha.45",
21
21
  "@viewfly/core": "^1.0.0-alpha.2",
22
22
  "@viewfly/hooks": "^1.0.0-alpha.2",
23
23
  "@viewfly/platform-browser": "^1.0.0-alpha.2",