@textbus/xnote 0.0.1-alpha.45 → 0.0.1-alpha.46

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.
@@ -715,6 +715,9 @@ class BlockquoteComponent extends Component {
715
715
  }) {
716
716
  super(textbus, state);
717
717
  }
718
+ getSlots() {
719
+ return [this.state.slot];
720
+ }
718
721
  setup() {
719
722
  useBlockContent(this.state.slot);
720
723
  }
@@ -755,7 +758,7 @@ function toBlockquote(textbus) {
755
758
  const index = parent.indexOf(current);
756
759
  parent.retain(index);
757
760
  commander.removeComponent(current);
758
- current.__slots__.get(0).sliceContent().forEach(i => {
761
+ current.slots.at(0).sliceContent().forEach(i => {
759
762
  parent.insert(i);
760
763
  });
761
764
  }
@@ -841,6 +844,9 @@ class HighlightBoxComponent extends Component {
841
844
  }) {
842
845
  super(textbus, state);
843
846
  }
847
+ getSlots() {
848
+ return [this.state.slot];
849
+ }
844
850
  setup() {
845
851
  useBlockContent(this.state.slot);
846
852
  }
@@ -921,6 +927,9 @@ class ParagraphComponent extends Component {
921
927
  }) {
922
928
  super(textbus, state);
923
929
  }
930
+ getSlots() {
931
+ return [this.state.slot];
932
+ }
924
933
  setup() {
925
934
  const injector = useContext();
926
935
  const commander = injector.get(Commander);
@@ -1169,6 +1178,9 @@ class SourceCodeComponent extends Component {
1169
1178
  theme: json.theme
1170
1179
  });
1171
1180
  }
1181
+ getSlots() {
1182
+ return this.state.slots.map(i => i.slot);
1183
+ }
1172
1184
  setup() {
1173
1185
  const textbus = useContext();
1174
1186
  const selection = useContext(Selection);
@@ -1807,6 +1819,9 @@ class TableComponent extends Component {
1807
1819
  this.focus = new Subject();
1808
1820
  this.tableSelection = createSignal(null);
1809
1821
  }
1822
+ getSlots() {
1823
+ return this.state.rows.map(i => i.cells.map(j => j.slot)).flat();
1824
+ }
1810
1825
  setup() {
1811
1826
  const selection = useContext(Selection);
1812
1827
  onFocusIn(() => {
@@ -2044,6 +2059,9 @@ class TodolistComponent extends Component {
2044
2059
  checked: json.checked
2045
2060
  });
2046
2061
  }
2062
+ getSlots() {
2063
+ return [this.state.slot];
2064
+ }
2047
2065
  setup() {
2048
2066
  const textbus = useContext();
2049
2067
  const commander = useContext(Commander);
@@ -2218,6 +2236,9 @@ class ListComponent extends Component {
2218
2236
  slot: textbus.get(Registry).createSlot(json.slot)
2219
2237
  });
2220
2238
  }
2239
+ getSlots() {
2240
+ return [this.state.slot];
2241
+ }
2221
2242
  setup() {
2222
2243
  const textbus = useContext();
2223
2244
  const commander = useContext(Commander);
@@ -2675,7 +2696,7 @@ function useBlockTransform() {
2675
2696
  const index = parent.indexOf(current);
2676
2697
  parent.retain(index);
2677
2698
  commander.removeComponent(current);
2678
- current.__slots__.get(0).sliceContent().forEach(i => {
2699
+ current.slots.at(0).sliceContent().forEach(i => {
2679
2700
  parent.insert(i);
2680
2701
  });
2681
2702
  }
@@ -3575,6 +3596,9 @@ class ImageComponent extends Component {
3575
3596
  static fromJSON(textbus, json) {
3576
3597
  return new ImageComponent(textbus, Object.assign({}, json));
3577
3598
  }
3599
+ getSlots() {
3600
+ return [];
3601
+ }
3578
3602
  }
3579
3603
  ImageComponent.type = ContentType.InlineComponent;
3580
3604
  ImageComponent.componentName = 'ImageComponent';
@@ -3614,8 +3638,8 @@ class VideoComponent extends Component {
3614
3638
  static fromJSON(textbus, json) {
3615
3639
  return new VideoComponent(textbus, Object.assign({}, json));
3616
3640
  }
3617
- setup() {
3618
- //
3641
+ getSlots() {
3642
+ return [];
3619
3643
  }
3620
3644
  }
3621
3645
  VideoComponent.type = ContentType.InlineComponent;
@@ -3723,6 +3747,9 @@ class KatexComponent extends Component {
3723
3747
  }) {
3724
3748
  super(textbus, state);
3725
3749
  }
3750
+ getSlots() {
3751
+ return [];
3752
+ }
3726
3753
  }
3727
3754
  KatexComponent.componentName = 'KatexComponent';
3728
3755
  KatexComponent.type = ContentType.InlineComponent;
@@ -4102,7 +4129,7 @@ const LeftToolbar = withAnnotation({
4102
4129
  if (!slot) {
4103
4130
  return;
4104
4131
  }
4105
- if (slot.parent.__slots__.length <= 1) {
4132
+ if (slot.parent.slots.length <= 1) {
4106
4133
  commander.removeComponent(slot.parent);
4107
4134
  }
4108
4135
  else {
@@ -4532,6 +4559,12 @@ class AtComponent extends Component {
4532
4559
  this.members = createSignal([]);
4533
4560
  this.selectedIndex = createSignal(0);
4534
4561
  }
4562
+ getSlots() {
4563
+ if (this.state.slot) {
4564
+ return [this.state.slot];
4565
+ }
4566
+ return [];
4567
+ }
4535
4568
  setup() {
4536
4569
  let isFocus = false;
4537
4570
  onFocus(() => {
@@ -4716,6 +4749,9 @@ class RootComponent extends Component {
4716
4749
  content
4717
4750
  });
4718
4751
  }
4752
+ getSlots() {
4753
+ return [this.state.content];
4754
+ }
4719
4755
  setup() {
4720
4756
  useBlockContent((slot) => slot === this.state.content);
4721
4757
  onCompositionStart(ev => {
@@ -5505,7 +5541,7 @@ function autoComplete(table) {
5505
5541
  function findFocusCell(table, slot) {
5506
5542
  var _a;
5507
5543
  while (slot) {
5508
- if (table.__slots__.includes(slot)) {
5544
+ if (table.slots.includes(slot)) {
5509
5545
  return slot;
5510
5546
  }
5511
5547
  slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
package/bundles/index.js CHANGED
@@ -717,6 +717,9 @@ class BlockquoteComponent extends core$1.Component {
717
717
  }) {
718
718
  super(textbus, state);
719
719
  }
720
+ getSlots() {
721
+ return [this.state.slot];
722
+ }
720
723
  setup() {
721
724
  useBlockContent(this.state.slot);
722
725
  }
@@ -757,7 +760,7 @@ function toBlockquote(textbus) {
757
760
  const index = parent.indexOf(current);
758
761
  parent.retain(index);
759
762
  commander.removeComponent(current);
760
- current.__slots__.get(0).sliceContent().forEach(i => {
763
+ current.slots.at(0).sliceContent().forEach(i => {
761
764
  parent.insert(i);
762
765
  });
763
766
  }
@@ -843,6 +846,9 @@ class HighlightBoxComponent extends core$1.Component {
843
846
  }) {
844
847
  super(textbus, state);
845
848
  }
849
+ getSlots() {
850
+ return [this.state.slot];
851
+ }
846
852
  setup() {
847
853
  useBlockContent(this.state.slot);
848
854
  }
@@ -923,6 +929,9 @@ class ParagraphComponent extends core$1.Component {
923
929
  }) {
924
930
  super(textbus, state);
925
931
  }
932
+ getSlots() {
933
+ return [this.state.slot];
934
+ }
926
935
  setup() {
927
936
  const injector = core$1.useContext();
928
937
  const commander = injector.get(core$1.Commander);
@@ -1171,6 +1180,9 @@ class SourceCodeComponent extends core$1.Component {
1171
1180
  theme: json.theme
1172
1181
  });
1173
1182
  }
1183
+ getSlots() {
1184
+ return this.state.slots.map(i => i.slot);
1185
+ }
1174
1186
  setup() {
1175
1187
  const textbus = core$1.useContext();
1176
1188
  const selection = core$1.useContext(core$1.Selection);
@@ -1809,6 +1821,9 @@ class TableComponent extends core$1.Component {
1809
1821
  this.focus = new core$1.Subject();
1810
1822
  this.tableSelection = core.createSignal(null);
1811
1823
  }
1824
+ getSlots() {
1825
+ return this.state.rows.map(i => i.cells.map(j => j.slot)).flat();
1826
+ }
1812
1827
  setup() {
1813
1828
  const selection = core$1.useContext(core$1.Selection);
1814
1829
  core$1.onFocusIn(() => {
@@ -2046,6 +2061,9 @@ class TodolistComponent extends core$1.Component {
2046
2061
  checked: json.checked
2047
2062
  });
2048
2063
  }
2064
+ getSlots() {
2065
+ return [this.state.slot];
2066
+ }
2049
2067
  setup() {
2050
2068
  const textbus = core$1.useContext();
2051
2069
  const commander = core$1.useContext(core$1.Commander);
@@ -2220,6 +2238,9 @@ class ListComponent extends core$1.Component {
2220
2238
  slot: textbus.get(core$1.Registry).createSlot(json.slot)
2221
2239
  });
2222
2240
  }
2241
+ getSlots() {
2242
+ return [this.state.slot];
2243
+ }
2223
2244
  setup() {
2224
2245
  const textbus = core$1.useContext();
2225
2246
  const commander = core$1.useContext(core$1.Commander);
@@ -2677,7 +2698,7 @@ function useBlockTransform() {
2677
2698
  const index = parent.indexOf(current);
2678
2699
  parent.retain(index);
2679
2700
  commander.removeComponent(current);
2680
- current.__slots__.get(0).sliceContent().forEach(i => {
2701
+ current.slots.at(0).sliceContent().forEach(i => {
2681
2702
  parent.insert(i);
2682
2703
  });
2683
2704
  }
@@ -3577,6 +3598,9 @@ class ImageComponent extends core$1.Component {
3577
3598
  static fromJSON(textbus, json) {
3578
3599
  return new ImageComponent(textbus, Object.assign({}, json));
3579
3600
  }
3601
+ getSlots() {
3602
+ return [];
3603
+ }
3580
3604
  }
3581
3605
  ImageComponent.type = core$1.ContentType.InlineComponent;
3582
3606
  ImageComponent.componentName = 'ImageComponent';
@@ -3616,8 +3640,8 @@ class VideoComponent extends core$1.Component {
3616
3640
  static fromJSON(textbus, json) {
3617
3641
  return new VideoComponent(textbus, Object.assign({}, json));
3618
3642
  }
3619
- setup() {
3620
- //
3643
+ getSlots() {
3644
+ return [];
3621
3645
  }
3622
3646
  }
3623
3647
  VideoComponent.type = core$1.ContentType.InlineComponent;
@@ -3725,6 +3749,9 @@ class KatexComponent extends core$1.Component {
3725
3749
  }) {
3726
3750
  super(textbus, state);
3727
3751
  }
3752
+ getSlots() {
3753
+ return [];
3754
+ }
3728
3755
  }
3729
3756
  KatexComponent.componentName = 'KatexComponent';
3730
3757
  KatexComponent.type = core$1.ContentType.InlineComponent;
@@ -4104,7 +4131,7 @@ const LeftToolbar = core.withAnnotation({
4104
4131
  if (!slot) {
4105
4132
  return;
4106
4133
  }
4107
- if (slot.parent.__slots__.length <= 1) {
4134
+ if (slot.parent.slots.length <= 1) {
4108
4135
  commander.removeComponent(slot.parent);
4109
4136
  }
4110
4137
  else {
@@ -4534,6 +4561,12 @@ class AtComponent extends core$1.Component {
4534
4561
  this.members = core.createSignal([]);
4535
4562
  this.selectedIndex = core.createSignal(0);
4536
4563
  }
4564
+ getSlots() {
4565
+ if (this.state.slot) {
4566
+ return [this.state.slot];
4567
+ }
4568
+ return [];
4569
+ }
4537
4570
  setup() {
4538
4571
  let isFocus = false;
4539
4572
  core$1.onFocus(() => {
@@ -4718,6 +4751,9 @@ class RootComponent extends core$1.Component {
4718
4751
  content
4719
4752
  });
4720
4753
  }
4754
+ getSlots() {
4755
+ return [this.state.content];
4756
+ }
4721
4757
  setup() {
4722
4758
  useBlockContent((slot) => slot === this.state.content);
4723
4759
  core$1.onCompositionStart(ev => {
@@ -5507,7 +5543,7 @@ function autoComplete(table) {
5507
5543
  function findFocusCell(table, slot) {
5508
5544
  var _a;
5509
5545
  while (slot) {
5510
- if (table.__slots__.includes(slot)) {
5546
+ if (table.slots.includes(slot)) {
5511
5547
  return slot;
5512
5548
  }
5513
5549
  slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
@@ -30,5 +30,6 @@ export declare class AtComponent extends Component<AtComponentState> {
30
30
  members: import("@viewfly/core").Signal<Member[]>;
31
31
  selectedIndex: import("@viewfly/core").Signal<number>;
32
32
  constructor(textbus: Textbus, state?: AtComponentState);
33
+ getSlots(): Slot[];
33
34
  setup(): void;
34
35
  }
@@ -11,6 +11,7 @@ export declare class BlockquoteComponent extends Component<BlockquoteComponentSt
11
11
  static zenCoding: ZenCodingGrammarInterceptor<BlockquoteComponentState>;
12
12
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<BlockquoteComponentState>): BlockquoteComponent;
13
13
  constructor(textbus: Textbus, state?: BlockquoteComponentState);
14
+ getSlots(): Slot[];
14
15
  setup(): void;
15
16
  }
16
17
  export declare function toBlockquote(textbus: Textbus): void;
@@ -12,6 +12,7 @@ export declare class HighlightBoxComponent extends Component<HighlightBoxCompone
12
12
  static type: ContentType;
13
13
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<HighlightBoxComponentState>): HighlightBoxComponent;
14
14
  constructor(textbus: Textbus, state?: HighlightBoxComponentState);
15
+ getSlots(): Slot[];
15
16
  setup(): void;
16
17
  }
17
18
  export declare function HighlightBoxView(props: ViewComponentProps<HighlightBoxComponent>): () => any;
@@ -1,4 +1,4 @@
1
- import { Component, ComponentStateLiteral, ContentType, Textbus } from '@textbus/core';
1
+ import { Component, ComponentStateLiteral, ContentType, Slot, Textbus } from '@textbus/core';
2
2
  import { ViewComponentProps } from '@textbus/adapter-viewfly';
3
3
  import { ComponentLoader } from '@textbus/platform-browser';
4
4
  import './image.component.scss';
@@ -11,6 +11,7 @@ export declare class ImageComponent extends Component<ImageComponentState> {
11
11
  static type: ContentType;
12
12
  static componentName: string;
13
13
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<ImageComponentState>): ImageComponent;
14
+ getSlots(): Slot[];
14
15
  }
15
16
  export declare function ImageView(props: ViewComponentProps<ImageComponent>): () => any;
16
17
  export declare const imageComponentLoader: ComponentLoader;
@@ -1,4 +1,4 @@
1
- import { Component, ComponentStateLiteral, ContentType, Textbus } from '@textbus/core';
1
+ import { Component, ComponentStateLiteral, ContentType, Slot, Textbus } from '@textbus/core';
2
2
  import { ViewComponentProps } from '@textbus/adapter-viewfly';
3
3
  import { ComponentLoader } from '@textbus/platform-browser';
4
4
  import './katex.component.scss';
@@ -10,6 +10,7 @@ export declare class KatexComponent extends Component<KatexComponentState> {
10
10
  static type: ContentType;
11
11
  static fromJSON(textbus: Textbus, state: ComponentStateLiteral<KatexComponentState>): KatexComponent;
12
12
  constructor(textbus: Textbus, state?: KatexComponentState);
13
+ getSlots(): Slot[];
13
14
  }
14
15
  export declare function KatexComponentView(props: ViewComponentProps<KatexComponent>): () => any;
15
16
  export declare const katexComponentLoader: ComponentLoader;
@@ -14,6 +14,7 @@ export declare class ListComponent extends Component<ListComponentState> {
14
14
  static type: ContentType;
15
15
  static zenCoding: ZenCodingGrammarInterceptor<ListComponentState>;
16
16
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<ListComponentState>): ListComponent;
17
+ getSlots(): Slot[];
17
18
  setup(): void;
18
19
  }
19
20
  export declare function ListComponentView(props: ViewComponentProps<ListComponent>): () => any;
@@ -10,6 +10,7 @@ export declare class ParagraphComponent extends Component<ParagraphComponentStat
10
10
  static type: ContentType;
11
11
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<ParagraphComponentState>): ParagraphComponent;
12
12
  constructor(textbus: Textbus, state?: ParagraphComponentState);
13
+ getSlots(): Slot[];
13
14
  setup(): void;
14
15
  }
15
16
  export declare function ParagraphView(props: ViewComponentProps<ParagraphComponent>): () => any;
@@ -10,6 +10,7 @@ export declare class RootComponent extends Component<RootComponentState> {
10
10
  static type: ContentType;
11
11
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<RootComponentState>): RootComponent;
12
12
  onCompositionStart: Subject<Event<Slot, CompositionStartEventData>>;
13
+ getSlots(): Slot[];
13
14
  setup(): void;
14
15
  afterCheck(): void;
15
16
  }
@@ -27,6 +27,7 @@ export declare class SourceCodeComponent extends Component<SourceCodeComponentSt
27
27
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<SourceCodeComponentState>): SourceCodeComponent;
28
28
  static zenCoding: ZenCodingGrammarInterceptor<SourceCodeComponentState>;
29
29
  focus: BehaviorSubject<boolean>;
30
+ getSlots(): Slot[];
30
31
  setup(): void;
31
32
  removeSlot(slot: Slot): boolean;
32
33
  cancelEmphasize: () => void;
@@ -21,6 +21,7 @@ export declare class TableComponent extends Component<TableComponentState> {
21
21
  constructor(textbus: Textbus, state?: TableComponentState);
22
22
  focus: Subject<boolean>;
23
23
  tableSelection: import("@viewfly/core").Signal<TableSelection | null>;
24
+ getSlots(): Slot[];
24
25
  setup(): void;
25
26
  deleteColumn(index: number): void;
26
27
  deleteRow(index: number): void;
@@ -11,6 +11,7 @@ export declare class TodolistComponent extends Component<TodolistComponentState>
11
11
  static componentName: string;
12
12
  static zenCoding: ZenCodingGrammarInterceptor<TodolistComponentState>;
13
13
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<TodolistComponentState>): TodolistComponent;
14
+ getSlots(): Slot[];
14
15
  setup(): void;
15
16
  }
16
17
  export declare function TodolistView(props: ViewComponentProps<TodolistComponent>): () => any;
@@ -11,7 +11,7 @@ export declare class VideoComponent extends Component<VideoComponentState> {
11
11
  static type: ContentType;
12
12
  static componentName: string;
13
13
  static fromJSON(textbus: Textbus, json: ComponentStateLiteral<VideoComponentState>): VideoComponent;
14
- setup(): void;
14
+ getSlots(): never[];
15
15
  }
16
16
  export declare function VideoView(props: ViewComponentProps<VideoComponent>): () => any;
17
17
  export declare const videoComponentLoader: ComponentLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.0.1-alpha.45",
3
+ "version": "0.0.1-alpha.46",
4
4
  "description": "A high-performance rich text editor that supports multiplayer online collaboration.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@tanbo/color": "^0.1.1",
30
- "@textbus/adapter-viewfly": "^4.0.0-alpha.69",
31
- "@textbus/collaborate": "^4.0.0-alpha.69",
32
- "@textbus/core": "^4.0.0-alpha.69",
33
- "@textbus/platform-browser": "^4.0.0-alpha.69",
30
+ "@textbus/adapter-viewfly": "^4.0.0-alpha.71",
31
+ "@textbus/collaborate": "^4.0.0-alpha.71",
32
+ "@textbus/core": "^4.0.0-alpha.71",
33
+ "@textbus/platform-browser": "^4.0.0-alpha.71",
34
34
  "@viewfly/core": "^1.0.0-alpha.17",
35
35
  "@viewfly/hooks": "^1.0.0-alpha.17",
36
36
  "@viewfly/platform-browser": "^1.0.0-alpha.17",