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

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.
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from '@viewfly/core/jsx-runtime';
2
2
  import { withScopedCSS } from '@viewfly/scoped-css';
3
- import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onUpdated, onMounted, InjectionToken, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, getCurrentInstance, watch } from '@viewfly/core';
4
- import { Subject, Selection, fromEvent, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, Slot, Component, Registry, Query, QueryStateType, createVNode, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, Formatter, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, merge, debounceTime, throttleTime, delay, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
3
+ import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onUpdated, onMounted, InjectionToken, getCurrentInstance, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, watch } from '@viewfly/core';
4
+ import { Subject, Selection, fromEvent, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, Formatter, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, throttleTime, delay, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
5
5
  import { VIEW_CONTAINER, isMac, DomAdapter, Input, SelectionBridge, BrowserModule, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, Parser } from '@textbus/platform-browser';
6
6
  import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
7
7
  import { useProduce } from '@viewfly/hooks';
@@ -30,6 +30,18 @@ PERFORMANCE OF THIS SOFTWARE.
30
30
  /* global Reflect, Promise, SuppressedError, Symbol */
31
31
 
32
32
 
33
+ function __rest(s, e) {
34
+ var t = {};
35
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
36
+ t[p] = s[p];
37
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
38
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
39
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
40
+ t[p[i]] = s[p[i]];
41
+ }
42
+ return t;
43
+ }
44
+
33
45
  function __decorate(decorators, target, key, desc) {
34
46
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
35
47
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -701,6 +713,26 @@ function useBlockContent(slot) {
701
713
  });
702
714
  }
703
715
 
716
+ function SlotRender(props) {
717
+ const adapter = inject(DomAdapter);
718
+ const instance = getCurrentInstance();
719
+ const slot = props.slot;
720
+ const sub = merge(slot.__changeMarker__.onChange, slot.__changeMarker__.onForceChange).subscribe(() => {
721
+ if (props.slot.__changeMarker__.dirty) {
722
+ instance.markAsDirtied();
723
+ }
724
+ });
725
+ onUnmounted(() => {
726
+ sub.unsubscribe();
727
+ });
728
+ return () => {
729
+ const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
730
+ return adapter.slotRender(slot, children => {
731
+ return createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
732
+ }, renderEnv);
733
+ };
734
+ }
735
+
704
736
  class BlockquoteComponent extends Component {
705
737
  static fromJSON(textbus, json) {
706
738
  const slot = textbus.get(Registry).createSlot(json.slot);
@@ -715,6 +747,9 @@ class BlockquoteComponent extends Component {
715
747
  }) {
716
748
  super(textbus, state);
717
749
  }
750
+ getSlots() {
751
+ return [this.state.slot];
752
+ }
718
753
  setup() {
719
754
  useBlockContent(this.state.slot);
720
755
  }
@@ -755,7 +790,7 @@ function toBlockquote(textbus) {
755
790
  const index = parent.indexOf(current);
756
791
  parent.retain(index);
757
792
  commander.removeComponent(current);
758
- current.__slots__.get(0).sliceContent().forEach(i => {
793
+ current.slots.at(0).sliceContent().forEach(i => {
759
794
  parent.insert(i);
760
795
  });
761
796
  }
@@ -794,14 +829,11 @@ function registerBlockquoteShortcut(textbus) {
794
829
  });
795
830
  }
796
831
  function BlockquoteView(props) {
797
- const adapter = inject(DomAdapter);
798
832
  const readonly = useReadonly();
799
833
  const output = useOutput();
800
834
  return () => {
801
835
  const slot = props.component.state.slot;
802
- return (jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
803
- return createVNode('div', null, children);
804
- }, readonly() || output()) }));
836
+ return (jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
805
837
  };
806
838
  }
807
839
  const blockquoteComponentLoader = {
@@ -841,6 +873,9 @@ class HighlightBoxComponent extends Component {
841
873
  }) {
842
874
  super(textbus, state);
843
875
  }
876
+ getSlots() {
877
+ return [this.state.slot];
878
+ }
844
879
  setup() {
845
880
  useBlockContent(this.state.slot);
846
881
  }
@@ -849,7 +884,6 @@ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '
849
884
  HighlightBoxComponent.componentName = 'HighlightBoxComponent';
850
885
  HighlightBoxComponent.type = ContentType.BlockComponent;
851
886
  function HighlightBoxView(props) {
852
- const adapter = inject(DomAdapter);
853
887
  const readonly = useReadonly();
854
888
  const output = useOutput();
855
889
  const emoji = [];
@@ -865,22 +899,14 @@ function HighlightBoxView(props) {
865
899
  return () => {
866
900
  const { state, name } = props.component;
867
901
  if (readonly() || output()) {
868
- return (jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsx("div", { class: "xnote-highlight-box-left", children: jsx("div", { class: "xnote-highlight-box-icon", children: jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
869
- return createVNode('div', {
870
- class: 'xnote-highlight-box-content'
871
- }, children);
872
- }, readonly() || output())] }));
902
+ return (jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsx("div", { class: "xnote-highlight-box-left", children: jsx("div", { class: "xnote-highlight-box-icon", children: jsx("button", { type: "button", children: state.type || '❤️' }) }) }), jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
873
903
  }
874
904
  return (jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsx("div", { class: "xnote-highlight-box-left", children: jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "282px", menu: jsxs("div", { class: "xnote-highlight-box-icons", children: [jsx("div", { class: "xnote-highlight-box-heading", children: "\u5E38\u7528" }), HighlightBoxComponent.defaultTypes.map(icon => {
875
905
  return (jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
876
906
  }), jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
877
907
  const icon = String.fromCodePoint(i);
878
908
  return (jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
879
- })] }), children: jsx("div", { class: "xnote-highlight-box-icon", children: jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
880
- return createVNode('div', {
881
- class: 'xnote-highlight-box-content'
882
- }, children);
883
- }, readonly() || output())] }));
909
+ })] }), children: jsx("div", { class: "xnote-highlight-box-icon", children: jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
884
910
  };
885
911
  }
886
912
  const highlightBoxComponentLoader = {
@@ -921,6 +947,9 @@ class ParagraphComponent extends Component {
921
947
  }) {
922
948
  super(textbus, state);
923
949
  }
950
+ getSlots() {
951
+ return [this.state.slot];
952
+ }
924
953
  setup() {
925
954
  const injector = useContext();
926
955
  const commander = injector.get(Commander);
@@ -948,14 +977,11 @@ class ParagraphComponent extends Component {
948
977
  ParagraphComponent.componentName = 'ParagraphComponent';
949
978
  ParagraphComponent.type = ContentType.BlockComponent;
950
979
  function ParagraphView(props) {
951
- const adapter = inject(DomAdapter);
952
980
  const readonly = useReadonly();
953
981
  const output = useOutput();
954
982
  return () => {
955
983
  const slot = props.component.state.slot;
956
- return (jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: adapter.slotRender(slot, children => {
957
- return (createVNode('div', null, children));
958
- }, readonly() || output()) }));
984
+ return (jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: jsx(SlotRender, { tag: "div", slot: slot, renderEnv: readonly() || output() }) }));
959
985
  };
960
986
  }
961
987
  const paragraphComponentLoader = {
@@ -1169,6 +1195,9 @@ class SourceCodeComponent extends Component {
1169
1195
  theme: json.theme
1170
1196
  });
1171
1197
  }
1198
+ getSlots() {
1199
+ return this.state.slots.map(i => i.slot);
1200
+ }
1172
1201
  setup() {
1173
1202
  const textbus = useContext();
1174
1203
  const selection = useContext(Selection);
@@ -1807,6 +1836,9 @@ class TableComponent extends Component {
1807
1836
  this.focus = new Subject();
1808
1837
  this.tableSelection = createSignal(null);
1809
1838
  }
1839
+ getSlots() {
1840
+ return this.state.rows.map(i => i.cells.map(j => j.slot)).flat();
1841
+ }
1810
1842
  setup() {
1811
1843
  const selection = useContext(Selection);
1812
1844
  onFocusIn(() => {
@@ -2044,6 +2076,9 @@ class TodolistComponent extends Component {
2044
2076
  checked: json.checked
2045
2077
  });
2046
2078
  }
2079
+ getSlots() {
2080
+ return [this.state.slot];
2081
+ }
2047
2082
  setup() {
2048
2083
  const textbus = useContext();
2049
2084
  const commander = useContext(Commander);
@@ -2124,7 +2159,6 @@ TodolistComponent.zenCoding = {
2124
2159
  }
2125
2160
  };
2126
2161
  function TodolistView(props) {
2127
- const adapter = inject(DomAdapter);
2128
2162
  const component = props.component;
2129
2163
  const state = component.state;
2130
2164
  function toggle() {
@@ -2153,11 +2187,7 @@ function TodolistView(props) {
2153
2187
  marginLeft: indent * 24 + 'px',
2154
2188
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2155
2189
  textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
2156
- }, children: [jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), adapter.slotRender(slot, children => {
2157
- return createVNode('div', {
2158
- class: 'xnote-todolist-content'
2159
- }, children);
2160
- }, readonly() || output())] }));
2190
+ }, children: [jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), jsx(SlotRender, { slot: slot, tag: 'div', class: 'xnote-todolist-content', renderEnv: readonly() || output() })] }));
2161
2191
  };
2162
2192
  }
2163
2193
  const todolistComponentLoader = {
@@ -2218,6 +2248,9 @@ class ListComponent extends Component {
2218
2248
  slot: textbus.get(Registry).createSlot(json.slot)
2219
2249
  });
2220
2250
  }
2251
+ getSlots() {
2252
+ return [this.state.slot];
2253
+ }
2221
2254
  setup() {
2222
2255
  const textbus = useContext();
2223
2256
  const commander = useContext(Commander);
@@ -2357,7 +2390,6 @@ function numberToLetter(num) {
2357
2390
  }).join('');
2358
2391
  }
2359
2392
  function ListComponentView(props) {
2360
- const adapter = inject(DomAdapter);
2361
2393
  const component = props.component;
2362
2394
  function reorder(is) {
2363
2395
  component.state.reorder = is;
@@ -2431,11 +2463,7 @@ function ListComponentView(props) {
2431
2463
  }, children: [jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2432
2464
  jsx("span", { class: "xnote-order-btn", children: icon })
2433
2465
  :
2434
- jsx(Dropdown, { menu: jsxs(Fragment, { children: [jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), adapter.slotRender(component.state.slot, children => {
2435
- return createVNode('div', {
2436
- class: 'xnote-list-content'
2437
- }, children);
2438
- }, readonly() || output())] }) }));
2466
+ jsx(Dropdown, { menu: jsxs(Fragment, { children: [jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), jsx(SlotRender, { slot: component.state.slot, class: 'xnote-list-content', renderEnv: readonly() || output() })] }) }));
2439
2467
  };
2440
2468
  }
2441
2469
  const listComponentLoader = {
@@ -2675,7 +2703,7 @@ function useBlockTransform() {
2675
2703
  const index = parent.indexOf(current);
2676
2704
  parent.retain(index);
2677
2705
  commander.removeComponent(current);
2678
- current.__slots__.get(0).sliceContent().forEach(i => {
2706
+ current.slots.at(0).sliceContent().forEach(i => {
2679
2707
  parent.insert(i);
2680
2708
  });
2681
2709
  }
@@ -3575,6 +3603,9 @@ class ImageComponent extends Component {
3575
3603
  static fromJSON(textbus, json) {
3576
3604
  return new ImageComponent(textbus, Object.assign({}, json));
3577
3605
  }
3606
+ getSlots() {
3607
+ return [];
3608
+ }
3578
3609
  }
3579
3610
  ImageComponent.type = ContentType.InlineComponent;
3580
3611
  ImageComponent.componentName = 'ImageComponent';
@@ -3614,8 +3645,8 @@ class VideoComponent extends Component {
3614
3645
  static fromJSON(textbus, json) {
3615
3646
  return new VideoComponent(textbus, Object.assign({}, json));
3616
3647
  }
3617
- setup() {
3618
- //
3648
+ getSlots() {
3649
+ return [];
3619
3650
  }
3620
3651
  }
3621
3652
  VideoComponent.type = ContentType.InlineComponent;
@@ -3723,6 +3754,9 @@ class KatexComponent extends Component {
3723
3754
  }) {
3724
3755
  super(textbus, state);
3725
3756
  }
3757
+ getSlots() {
3758
+ return [];
3759
+ }
3726
3760
  }
3727
3761
  KatexComponent.componentName = 'KatexComponent';
3728
3762
  KatexComponent.type = ContentType.InlineComponent;
@@ -4102,7 +4136,7 @@ const LeftToolbar = withAnnotation({
4102
4136
  if (!slot) {
4103
4137
  return;
4104
4138
  }
4105
- if (slot.parent.__slots__.length <= 1) {
4139
+ if (slot.parent.slots.length <= 1) {
4106
4140
  commander.removeComponent(slot.parent);
4107
4141
  }
4108
4142
  else {
@@ -4532,6 +4566,12 @@ class AtComponent extends Component {
4532
4566
  this.members = createSignal([]);
4533
4567
  this.selectedIndex = createSignal(0);
4534
4568
  }
4569
+ getSlots() {
4570
+ if (this.state.slot) {
4571
+ return [this.state.slot];
4572
+ }
4573
+ return [];
4574
+ }
4535
4575
  setup() {
4536
4576
  let isFocus = false;
4537
4577
  onFocus(() => {
@@ -4619,7 +4659,6 @@ AtComponent.componentName = 'AtComponent';
4619
4659
  AtComponent.type = ContentType.InlineComponent;
4620
4660
 
4621
4661
  function AtComponentView(props) {
4622
- const adapter = inject(DomAdapter);
4623
4662
  const selection = inject(Selection);
4624
4663
  const dropdownRef = createRef();
4625
4664
  const subscription = props.component.focus.subscribe((b) => {
@@ -4660,11 +4699,7 @@ function AtComponentView(props) {
4660
4699
  return (jsxs("div", { class: "xnote-at xnote-at-complete", "data-info": encodeURIComponent(JSON.stringify(userInfo)), ref: props.rootRef, "data-component": props.component.name, children: [jsx("span", { children: "@" }), userInfo.name] }));
4661
4700
  }
4662
4701
  if (readonly() || output()) {
4663
- return (jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4664
- return createVNode('span', {
4665
- class: 'xnote-at-input'
4666
- }, children);
4667
- })] }));
4702
+ return (jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsx("span", { children: "@" }), slot && jsx(SlotRender, { slot: slot, class: 'xnote-at-input', tag: "span" })] }));
4668
4703
  }
4669
4704
  const members = props.component.members();
4670
4705
  return (jsx("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: jsxs(Dropdown, { trigger: 'none', ref: dropdownRef, menu: jsx("div", { class: "xnote-at-menu", ref: membersRef, children: members.map((member, index) => {
@@ -4680,11 +4715,7 @@ function AtComponentView(props) {
4680
4715
  selection.selectComponentEnd(props.component);
4681
4716
  }, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsx("img", { src: member.avatar, alt: member.name }) :
4682
4717
  jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color }, children: member.name }) }), jsxs("div", { class: "xnote-at-member-info", children: [jsx("div", { class: "xnote-at-member-name", children: member.name }), jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
4683
- }) }), children: [jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4684
- return createVNode('span', {
4685
- class: 'xnote-at-input'
4686
- }, children);
4687
- })] }) }));
4718
+ }) }), children: [jsx("span", { children: "@" }), slot && jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
4688
4719
  };
4689
4720
  }
4690
4721
  const atComponentLoader = {
@@ -4716,6 +4747,9 @@ class RootComponent extends Component {
4716
4747
  content
4717
4748
  });
4718
4749
  }
4750
+ getSlots() {
4751
+ return [this.state.content];
4752
+ }
4719
4753
  setup() {
4720
4754
  useBlockContent((slot) => slot === this.state.content);
4721
4755
  onCompositionStart(ev => {
@@ -4743,7 +4777,6 @@ class RootComponent extends Component {
4743
4777
  RootComponent.componentName = 'RootComponent';
4744
4778
  RootComponent.type = ContentType.BlockComponent;
4745
4779
  function RootView(props) {
4746
- const adapter = inject(DomAdapter);
4747
4780
  const { content } = props.component.state;
4748
4781
  const ref = createDynamicRef(node => {
4749
4782
  const sub = props.component.onCompositionStart.subscribe(() => {
@@ -4760,12 +4793,7 @@ function RootView(props) {
4760
4793
  const output = useOutput();
4761
4794
  return () => {
4762
4795
  const { rootRef } = props;
4763
- return (jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-component": props.component.name, children: adapter.slotRender(content, children => {
4764
- return (createVNode('div', {
4765
- class: 'xnote-content',
4766
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4767
- }, children));
4768
- }, readonly() || output()) }));
4796
+ return (jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-component": props.component.name, children: jsx(SlotRender, { slot: content, tag: "div", class: "xnote-content", "data-placeholder": content.isEmpty ? '请输入内容' : '', renderEnv: readonly() || output() }) }));
4769
4797
  };
4770
4798
  }
4771
4799
  const rootComponentLoader = {
@@ -5284,6 +5312,7 @@ function SelectionMask(props) {
5284
5312
  });
5285
5313
  }
5286
5314
 
5315
+ // import { SlotRender } from '../SlotRender'
5287
5316
  const TableComponentView = withAnnotation({
5288
5317
  providers: [TableService]
5289
5318
  }, function TableComponentView(props) {
@@ -5332,7 +5361,7 @@ const TableComponentView = withAnnotation({
5332
5361
  }) }, rowMapping.get(row)));
5333
5362
  }) })] }) }) }) }));
5334
5363
  }
5335
- return (jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsx(Scroll, { isFocus: isFocus, children: jsxs("div", { class: "xnote-table-container", children: [jsxs("table", { ref: tableRef, class: [
5364
+ return (jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.layoutWidth.join(',')}]`, children: jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsx(Scroll, { isFocus: isFocus, children: jsxs("div", { class: "xnote-table-container", children: [jsxs("table", { ref: tableRef, class: [
5336
5365
  'xnote-table-content',
5337
5366
  {
5338
5367
  'hide-selection': props.component.tableSelection()
@@ -5357,10 +5386,11 @@ const tableComponentLoader = {
5357
5386
  return element.dataset.component === TableComponent.componentName || element.tagName === 'TABLE';
5358
5387
  },
5359
5388
  read(element, textbus, slotParser) {
5389
+ let content = element;
5360
5390
  if (element.tagName === 'DIV') {
5361
- element = element.querySelector('.xnote-table-content');
5391
+ content = element.querySelector('.xnote-table-content');
5362
5392
  }
5363
- const { tHead, tBodies, tFoot } = element;
5393
+ const { tHead, tBodies, tFoot } = content;
5364
5394
  const headers = [];
5365
5395
  const bodies = [];
5366
5396
  if (tHead) {
@@ -5505,7 +5535,7 @@ function autoComplete(table) {
5505
5535
  function findFocusCell(table, slot) {
5506
5536
  var _a;
5507
5537
  while (slot) {
5508
- if (table.__slots__.includes(slot)) {
5538
+ if (table.slots.includes(slot)) {
5509
5539
  return slot;
5510
5540
  }
5511
5541
  slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
package/bundles/index.js CHANGED
@@ -32,6 +32,18 @@ PERFORMANCE OF THIS SOFTWARE.
32
32
  /* global Reflect, Promise, SuppressedError, Symbol */
33
33
 
34
34
 
35
+ function __rest(s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ }
46
+
35
47
  function __decorate(decorators, target, key, desc) {
36
48
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
37
49
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -703,6 +715,26 @@ function useBlockContent(slot) {
703
715
  });
704
716
  }
705
717
 
718
+ function SlotRender(props) {
719
+ const adapter = core.inject(platformBrowser.DomAdapter);
720
+ const instance = core.getCurrentInstance();
721
+ const slot = props.slot;
722
+ const sub = core$1.merge(slot.__changeMarker__.onChange, slot.__changeMarker__.onForceChange).subscribe(() => {
723
+ if (props.slot.__changeMarker__.dirty) {
724
+ instance.markAsDirtied();
725
+ }
726
+ });
727
+ core.onUnmounted(() => {
728
+ sub.unsubscribe();
729
+ });
730
+ return () => {
731
+ const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
732
+ return adapter.slotRender(slot, children => {
733
+ return core$1.createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
734
+ }, renderEnv);
735
+ };
736
+ }
737
+
706
738
  class BlockquoteComponent extends core$1.Component {
707
739
  static fromJSON(textbus, json) {
708
740
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
@@ -717,6 +749,9 @@ class BlockquoteComponent extends core$1.Component {
717
749
  }) {
718
750
  super(textbus, state);
719
751
  }
752
+ getSlots() {
753
+ return [this.state.slot];
754
+ }
720
755
  setup() {
721
756
  useBlockContent(this.state.slot);
722
757
  }
@@ -757,7 +792,7 @@ function toBlockquote(textbus) {
757
792
  const index = parent.indexOf(current);
758
793
  parent.retain(index);
759
794
  commander.removeComponent(current);
760
- current.__slots__.get(0).sliceContent().forEach(i => {
795
+ current.slots.at(0).sliceContent().forEach(i => {
761
796
  parent.insert(i);
762
797
  });
763
798
  }
@@ -796,14 +831,11 @@ function registerBlockquoteShortcut(textbus) {
796
831
  });
797
832
  }
798
833
  function BlockquoteView(props) {
799
- const adapter = core.inject(platformBrowser.DomAdapter);
800
834
  const readonly = useReadonly();
801
835
  const output = useOutput();
802
836
  return () => {
803
837
  const slot = props.component.state.slot;
804
- return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
805
- return core$1.createVNode('div', null, children);
806
- }, readonly() || output()) }));
838
+ return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
807
839
  };
808
840
  }
809
841
  const blockquoteComponentLoader = {
@@ -843,6 +875,9 @@ class HighlightBoxComponent extends core$1.Component {
843
875
  }) {
844
876
  super(textbus, state);
845
877
  }
878
+ getSlots() {
879
+ return [this.state.slot];
880
+ }
846
881
  setup() {
847
882
  useBlockContent(this.state.slot);
848
883
  }
@@ -851,7 +886,6 @@ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '
851
886
  HighlightBoxComponent.componentName = 'HighlightBoxComponent';
852
887
  HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
853
888
  function HighlightBoxView(props) {
854
- const adapter = core.inject(platformBrowser.DomAdapter);
855
889
  const readonly = useReadonly();
856
890
  const output = useOutput();
857
891
  const emoji = [];
@@ -867,22 +901,14 @@ function HighlightBoxView(props) {
867
901
  return () => {
868
902
  const { state, name } = props.component;
869
903
  if (readonly() || output()) {
870
- return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
871
- return core$1.createVNode('div', {
872
- class: 'xnote-highlight-box-content'
873
- }, children);
874
- }, readonly() || output())] }));
904
+ return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
875
905
  }
876
906
  return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "282px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u5E38\u7528" }), HighlightBoxComponent.defaultTypes.map(icon => {
877
907
  return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
878
908
  }), jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
879
909
  const icon = String.fromCodePoint(i);
880
910
  return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
881
- })] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
882
- return core$1.createVNode('div', {
883
- class: 'xnote-highlight-box-content'
884
- }, children);
885
- }, readonly() || output())] }));
911
+ })] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
886
912
  };
887
913
  }
888
914
  const highlightBoxComponentLoader = {
@@ -923,6 +949,9 @@ class ParagraphComponent extends core$1.Component {
923
949
  }) {
924
950
  super(textbus, state);
925
951
  }
952
+ getSlots() {
953
+ return [this.state.slot];
954
+ }
926
955
  setup() {
927
956
  const injector = core$1.useContext();
928
957
  const commander = injector.get(core$1.Commander);
@@ -950,14 +979,11 @@ class ParagraphComponent extends core$1.Component {
950
979
  ParagraphComponent.componentName = 'ParagraphComponent';
951
980
  ParagraphComponent.type = core$1.ContentType.BlockComponent;
952
981
  function ParagraphView(props) {
953
- const adapter = core.inject(platformBrowser.DomAdapter);
954
982
  const readonly = useReadonly();
955
983
  const output = useOutput();
956
984
  return () => {
957
985
  const slot = props.component.state.slot;
958
- return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: adapter.slotRender(slot, children => {
959
- return (core$1.createVNode('div', null, children));
960
- }, readonly() || output()) }));
986
+ return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: jsxRuntime.jsx(SlotRender, { tag: "div", slot: slot, renderEnv: readonly() || output() }) }));
961
987
  };
962
988
  }
963
989
  const paragraphComponentLoader = {
@@ -1171,6 +1197,9 @@ class SourceCodeComponent extends core$1.Component {
1171
1197
  theme: json.theme
1172
1198
  });
1173
1199
  }
1200
+ getSlots() {
1201
+ return this.state.slots.map(i => i.slot);
1202
+ }
1174
1203
  setup() {
1175
1204
  const textbus = core$1.useContext();
1176
1205
  const selection = core$1.useContext(core$1.Selection);
@@ -1809,6 +1838,9 @@ class TableComponent extends core$1.Component {
1809
1838
  this.focus = new core$1.Subject();
1810
1839
  this.tableSelection = core.createSignal(null);
1811
1840
  }
1841
+ getSlots() {
1842
+ return this.state.rows.map(i => i.cells.map(j => j.slot)).flat();
1843
+ }
1812
1844
  setup() {
1813
1845
  const selection = core$1.useContext(core$1.Selection);
1814
1846
  core$1.onFocusIn(() => {
@@ -2046,6 +2078,9 @@ class TodolistComponent extends core$1.Component {
2046
2078
  checked: json.checked
2047
2079
  });
2048
2080
  }
2081
+ getSlots() {
2082
+ return [this.state.slot];
2083
+ }
2049
2084
  setup() {
2050
2085
  const textbus = core$1.useContext();
2051
2086
  const commander = core$1.useContext(core$1.Commander);
@@ -2126,7 +2161,6 @@ TodolistComponent.zenCoding = {
2126
2161
  }
2127
2162
  };
2128
2163
  function TodolistView(props) {
2129
- const adapter = core.inject(platformBrowser.DomAdapter);
2130
2164
  const component = props.component;
2131
2165
  const state = component.state;
2132
2166
  function toggle() {
@@ -2155,11 +2189,7 @@ function TodolistView(props) {
2155
2189
  marginLeft: indent * 24 + 'px',
2156
2190
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2157
2191
  textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
2158
- }, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), adapter.slotRender(slot, children => {
2159
- return core$1.createVNode('div', {
2160
- class: 'xnote-todolist-content'
2161
- }, children);
2162
- }, readonly() || output())] }));
2192
+ }, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'div', class: 'xnote-todolist-content', renderEnv: readonly() || output() })] }));
2163
2193
  };
2164
2194
  }
2165
2195
  const todolistComponentLoader = {
@@ -2220,6 +2250,9 @@ class ListComponent extends core$1.Component {
2220
2250
  slot: textbus.get(core$1.Registry).createSlot(json.slot)
2221
2251
  });
2222
2252
  }
2253
+ getSlots() {
2254
+ return [this.state.slot];
2255
+ }
2223
2256
  setup() {
2224
2257
  const textbus = core$1.useContext();
2225
2258
  const commander = core$1.useContext(core$1.Commander);
@@ -2359,7 +2392,6 @@ function numberToLetter(num) {
2359
2392
  }).join('');
2360
2393
  }
2361
2394
  function ListComponentView(props) {
2362
- const adapter = core.inject(platformBrowser.DomAdapter);
2363
2395
  const component = props.component;
2364
2396
  function reorder(is) {
2365
2397
  component.state.reorder = is;
@@ -2433,11 +2465,7 @@ function ListComponentView(props) {
2433
2465
  }, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2434
2466
  jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
2435
2467
  :
2436
- jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), adapter.slotRender(component.state.slot, children => {
2437
- return core$1.createVNode('div', {
2438
- class: 'xnote-list-content'
2439
- }, children);
2440
- }, readonly() || output())] }) }));
2468
+ jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), jsxRuntime.jsx(SlotRender, { slot: component.state.slot, class: 'xnote-list-content', renderEnv: readonly() || output() })] }) }));
2441
2469
  };
2442
2470
  }
2443
2471
  const listComponentLoader = {
@@ -2677,7 +2705,7 @@ function useBlockTransform() {
2677
2705
  const index = parent.indexOf(current);
2678
2706
  parent.retain(index);
2679
2707
  commander.removeComponent(current);
2680
- current.__slots__.get(0).sliceContent().forEach(i => {
2708
+ current.slots.at(0).sliceContent().forEach(i => {
2681
2709
  parent.insert(i);
2682
2710
  });
2683
2711
  }
@@ -3577,6 +3605,9 @@ class ImageComponent extends core$1.Component {
3577
3605
  static fromJSON(textbus, json) {
3578
3606
  return new ImageComponent(textbus, Object.assign({}, json));
3579
3607
  }
3608
+ getSlots() {
3609
+ return [];
3610
+ }
3580
3611
  }
3581
3612
  ImageComponent.type = core$1.ContentType.InlineComponent;
3582
3613
  ImageComponent.componentName = 'ImageComponent';
@@ -3616,8 +3647,8 @@ class VideoComponent extends core$1.Component {
3616
3647
  static fromJSON(textbus, json) {
3617
3648
  return new VideoComponent(textbus, Object.assign({}, json));
3618
3649
  }
3619
- setup() {
3620
- //
3650
+ getSlots() {
3651
+ return [];
3621
3652
  }
3622
3653
  }
3623
3654
  VideoComponent.type = core$1.ContentType.InlineComponent;
@@ -3725,6 +3756,9 @@ class KatexComponent extends core$1.Component {
3725
3756
  }) {
3726
3757
  super(textbus, state);
3727
3758
  }
3759
+ getSlots() {
3760
+ return [];
3761
+ }
3728
3762
  }
3729
3763
  KatexComponent.componentName = 'KatexComponent';
3730
3764
  KatexComponent.type = core$1.ContentType.InlineComponent;
@@ -4104,7 +4138,7 @@ const LeftToolbar = core.withAnnotation({
4104
4138
  if (!slot) {
4105
4139
  return;
4106
4140
  }
4107
- if (slot.parent.__slots__.length <= 1) {
4141
+ if (slot.parent.slots.length <= 1) {
4108
4142
  commander.removeComponent(slot.parent);
4109
4143
  }
4110
4144
  else {
@@ -4534,6 +4568,12 @@ class AtComponent extends core$1.Component {
4534
4568
  this.members = core.createSignal([]);
4535
4569
  this.selectedIndex = core.createSignal(0);
4536
4570
  }
4571
+ getSlots() {
4572
+ if (this.state.slot) {
4573
+ return [this.state.slot];
4574
+ }
4575
+ return [];
4576
+ }
4537
4577
  setup() {
4538
4578
  let isFocus = false;
4539
4579
  core$1.onFocus(() => {
@@ -4621,7 +4661,6 @@ AtComponent.componentName = 'AtComponent';
4621
4661
  AtComponent.type = core$1.ContentType.InlineComponent;
4622
4662
 
4623
4663
  function AtComponentView(props) {
4624
- const adapter = core.inject(platformBrowser.DomAdapter);
4625
4664
  const selection = core.inject(core$1.Selection);
4626
4665
  const dropdownRef = core.createRef();
4627
4666
  const subscription = props.component.focus.subscribe((b) => {
@@ -4662,11 +4701,7 @@ function AtComponentView(props) {
4662
4701
  return (jsxRuntime.jsxs("div", { class: "xnote-at xnote-at-complete", "data-info": encodeURIComponent(JSON.stringify(userInfo)), ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), userInfo.name] }));
4663
4702
  }
4664
4703
  if (readonly() || output()) {
4665
- return (jsxRuntime.jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4666
- return core$1.createVNode('span', {
4667
- class: 'xnote-at-input'
4668
- }, children);
4669
- })] }));
4704
+ return (jsxRuntime.jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, class: 'xnote-at-input', tag: "span" })] }));
4670
4705
  }
4671
4706
  const members = props.component.members();
4672
4707
  return (jsxRuntime.jsx("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsxs(Dropdown, { trigger: 'none', ref: dropdownRef, menu: jsxRuntime.jsx("div", { class: "xnote-at-menu", ref: membersRef, children: members.map((member, index) => {
@@ -4682,11 +4717,7 @@ function AtComponentView(props) {
4682
4717
  selection.selectComponentEnd(props.component);
4683
4718
  }, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsxRuntime.jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsxRuntime.jsx("img", { src: member.avatar, alt: member.name }) :
4684
4719
  jsxRuntime.jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color: color$1 }, children: member.name }) }), jsxRuntime.jsxs("div", { class: "xnote-at-member-info", children: [jsxRuntime.jsx("div", { class: "xnote-at-member-name", children: member.name }), jsxRuntime.jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
4685
- }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4686
- return core$1.createVNode('span', {
4687
- class: 'xnote-at-input'
4688
- }, children);
4689
- })] }) }));
4720
+ }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
4690
4721
  };
4691
4722
  }
4692
4723
  const atComponentLoader = {
@@ -4718,6 +4749,9 @@ class RootComponent extends core$1.Component {
4718
4749
  content
4719
4750
  });
4720
4751
  }
4752
+ getSlots() {
4753
+ return [this.state.content];
4754
+ }
4721
4755
  setup() {
4722
4756
  useBlockContent((slot) => slot === this.state.content);
4723
4757
  core$1.onCompositionStart(ev => {
@@ -4745,7 +4779,6 @@ class RootComponent extends core$1.Component {
4745
4779
  RootComponent.componentName = 'RootComponent';
4746
4780
  RootComponent.type = core$1.ContentType.BlockComponent;
4747
4781
  function RootView(props) {
4748
- const adapter = core.inject(platformBrowser.DomAdapter);
4749
4782
  const { content } = props.component.state;
4750
4783
  const ref = core.createDynamicRef(node => {
4751
4784
  const sub = props.component.onCompositionStart.subscribe(() => {
@@ -4762,12 +4795,7 @@ function RootView(props) {
4762
4795
  const output = useOutput();
4763
4796
  return () => {
4764
4797
  const { rootRef } = props;
4765
- return (jsxRuntime.jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-component": props.component.name, children: adapter.slotRender(content, children => {
4766
- return (core$1.createVNode('div', {
4767
- class: 'xnote-content',
4768
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4769
- }, children));
4770
- }, readonly() || output()) }));
4798
+ return (jsxRuntime.jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: content, tag: "div", class: "xnote-content", "data-placeholder": content.isEmpty ? '请输入内容' : '', renderEnv: readonly() || output() }) }));
4771
4799
  };
4772
4800
  }
4773
4801
  const rootComponentLoader = {
@@ -5286,6 +5314,7 @@ function SelectionMask(props) {
5286
5314
  });
5287
5315
  }
5288
5316
 
5317
+ // import { SlotRender } from '../SlotRender'
5289
5318
  const TableComponentView = core.withAnnotation({
5290
5319
  providers: [TableService]
5291
5320
  }, function TableComponentView(props) {
@@ -5334,7 +5363,7 @@ const TableComponentView = core.withAnnotation({
5334
5363
  }) }, rowMapping.get(row)));
5335
5364
  }) })] }) }) }) }));
5336
5365
  }
5337
- return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
5366
+ return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.layoutWidth.join(',')}]`, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
5338
5367
  'xnote-table-content',
5339
5368
  {
5340
5369
  'hide-selection': props.component.tableSelection()
@@ -5359,10 +5388,11 @@ const tableComponentLoader = {
5359
5388
  return element.dataset.component === TableComponent.componentName || element.tagName === 'TABLE';
5360
5389
  },
5361
5390
  read(element, textbus, slotParser) {
5391
+ let content = element;
5362
5392
  if (element.tagName === 'DIV') {
5363
- element = element.querySelector('.xnote-table-content');
5393
+ content = element.querySelector('.xnote-table-content');
5364
5394
  }
5365
- const { tHead, tBodies, tFoot } = element;
5395
+ const { tHead, tBodies, tFoot } = content;
5366
5396
  const headers = [];
5367
5397
  const bodies = [];
5368
5398
  if (tHead) {
@@ -5507,7 +5537,7 @@ function autoComplete(table) {
5507
5537
  function findFocusCell(table, slot) {
5508
5538
  var _a;
5509
5539
  while (slot) {
5510
- if (table.__slots__.includes(slot)) {
5540
+ if (table.slots.includes(slot)) {
5511
5541
  return slot;
5512
5542
  }
5513
5543
  slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
@@ -0,0 +1,14 @@
1
+ import { Slot } from '@textbus/core';
2
+ import { DynamicRef } from '@viewfly/core';
3
+ import { HTMLAttributes } from '@viewfly/platform-browser';
4
+ interface Props extends HTMLAttributes<unknown> {
5
+ slot: Slot;
6
+ /** 默认值为 div */
7
+ tag?: string;
8
+ class?: string;
9
+ renderEnv?: boolean;
10
+ elRef?: DynamicRef<HTMLElement>;
11
+ elKey?: number | string;
12
+ }
13
+ export declare function SlotRender(props: Props): () => any;
14
+ export {};
@@ -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.47",
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,14 +27,14 @@
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",
34
- "@viewfly/core": "^1.0.0-alpha.17",
35
- "@viewfly/hooks": "^1.0.0-alpha.17",
36
- "@viewfly/platform-browser": "^1.0.0-alpha.17",
37
- "@viewfly/scoped-css": "^1.0.0-alpha.17",
30
+ "@textbus/adapter-viewfly": "^4.0.0-alpha.72",
31
+ "@textbus/collaborate": "^4.0.0-alpha.72",
32
+ "@textbus/core": "^4.0.0-alpha.72",
33
+ "@textbus/platform-browser": "^4.0.0-alpha.72",
34
+ "@viewfly/core": "^1.0.0-alpha.18",
35
+ "@viewfly/hooks": "^1.0.0-alpha.18",
36
+ "@viewfly/platform-browser": "^1.0.0-alpha.18",
37
+ "@viewfly/scoped-css": "^1.0.0-alpha.18",
38
38
  "highlight.js": "^11.9.0",
39
39
  "katex": "^0.16.10"
40
40
  },