@textbus/xnote 0.0.1-alpha.35 → 0.0.1-alpha.37

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, 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, createVNode, Slot, Component, Registry, Query, QueryStateType, BehaviorSubject, 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';
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);
@@ -700,6 +712,23 @@ function useBlockContent(slot) {
700
712
  });
701
713
  }
702
714
 
715
+ function SlotRender(props) {
716
+ const adaper = inject(DomAdapter);
717
+ const instance = getCurrentInstance();
718
+ const sub = props.slot.__changeMarker__.onChange.subscribe(() => {
719
+ instance.markAsDirtied();
720
+ });
721
+ onUnmounted(() => {
722
+ sub.unsubscribe();
723
+ });
724
+ return () => {
725
+ const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
726
+ return adaper.slotRender(slot, children => {
727
+ return createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
728
+ }, renderEnv);
729
+ };
730
+ }
731
+
703
732
  class BlockquoteComponent extends Component {
704
733
  static fromJSON(textbus, json) {
705
734
  const slot = textbus.get(Registry).createSlot(json.slot);
@@ -793,14 +822,11 @@ function registerBlockquoteShortcut(textbus) {
793
822
  });
794
823
  }
795
824
  function BlockquoteView(props) {
796
- const adapter = inject(DomAdapter);
797
825
  const readonly = useReadonly();
798
826
  const output = useOutput();
799
827
  return () => {
800
828
  const slot = props.component.state.slot;
801
- return (jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
802
- return createVNode('div', null, children);
803
- }, readonly() || output()) }));
829
+ return (jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
804
830
  };
805
831
  }
806
832
  const blockquoteComponentLoader = {
@@ -848,7 +874,6 @@ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '
848
874
  HighlightBoxComponent.componentName = 'HighlightBoxComponent';
849
875
  HighlightBoxComponent.type = ContentType.BlockComponent;
850
876
  function HighlightBoxView(props) {
851
- const adapter = inject(DomAdapter);
852
877
  const readonly = useReadonly();
853
878
  const output = useOutput();
854
879
  const emoji = [];
@@ -864,22 +889,14 @@ function HighlightBoxView(props) {
864
889
  return () => {
865
890
  const { state, name } = props.component;
866
891
  if (readonly() || output()) {
867
- 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 => {
868
- return createVNode('div', {
869
- class: 'xnote-highlight-box-content'
870
- }, children);
871
- }, readonly() || output())] }));
892
+ 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() })] }));
872
893
  }
873
894
  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 => {
874
895
  return (jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
875
896
  }), jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
876
897
  const icon = String.fromCodePoint(i);
877
898
  return (jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
878
- })] }), children: jsx("div", { class: "xnote-highlight-box-icon", children: jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
879
- return createVNode('div', {
880
- class: 'xnote-highlight-box-content'
881
- }, children);
882
- }, readonly() || output())] }));
899
+ })] }), 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() })] }));
883
900
  };
884
901
  }
885
902
  const highlightBoxComponentLoader = {
@@ -947,14 +964,11 @@ class ParagraphComponent extends Component {
947
964
  ParagraphComponent.componentName = 'ParagraphComponent';
948
965
  ParagraphComponent.type = ContentType.BlockComponent;
949
966
  function ParagraphView(props) {
950
- const adapter = inject(DomAdapter);
951
967
  const readonly = useReadonly();
952
968
  const output = useOutput();
953
969
  return () => {
954
970
  const slot = props.component.state.slot;
955
- return (jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: adapter.slotRender(slot, children => {
956
- return (createVNode('div', null, children));
957
- }, readonly() || output()) }));
971
+ return (jsx(SlotRender, { tag: 'div', slot: slot, class: "xnote-paragraph", elRef: props.rootRef, "data-component": ParagraphComponent.componentName, renderEnv: readonly() || output() }));
958
972
  };
959
973
  }
960
974
  const paragraphComponentLoader = {
@@ -2106,7 +2120,6 @@ TodolistComponent.zenCoding = {
2106
2120
  }
2107
2121
  };
2108
2122
  function TodolistView(props) {
2109
- const adapter = inject(DomAdapter);
2110
2123
  const component = props.component;
2111
2124
  const state = component.state;
2112
2125
  function toggle() {
@@ -2135,11 +2148,7 @@ function TodolistView(props) {
2135
2148
  marginLeft: indent * 24 + 'px',
2136
2149
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2137
2150
  textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
2138
- }, 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 => {
2139
- return createVNode('div', {
2140
- class: 'xnote-todolist-content'
2141
- }, children);
2142
- }, readonly() || output())] }));
2151
+ }, 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() })] }));
2143
2152
  };
2144
2153
  }
2145
2154
  const todolistComponentLoader = {
@@ -2339,7 +2348,6 @@ function numberToLetter(num) {
2339
2348
  }).join('');
2340
2349
  }
2341
2350
  function ListComponentView(props) {
2342
- const adapter = inject(DomAdapter);
2343
2351
  const component = props.component;
2344
2352
  function reorder(is) {
2345
2353
  component.state.reorder = is;
@@ -2413,11 +2421,7 @@ function ListComponentView(props) {
2413
2421
  }, children: [jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2414
2422
  jsx("span", { class: "xnote-order-btn", children: icon })
2415
2423
  :
2416
- 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 => {
2417
- return createVNode('div', {
2418
- class: 'xnote-list-content'
2419
- }, children);
2420
- }, readonly() || output())] }) }));
2424
+ 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() })] }) }));
2421
2425
  };
2422
2426
  }
2423
2427
  const listComponentLoader = {
@@ -4601,7 +4605,6 @@ AtComponent.componentName = 'AtComponent';
4601
4605
  AtComponent.type = ContentType.InlineComponent;
4602
4606
 
4603
4607
  function AtComponentView(props) {
4604
- const adapter = inject(DomAdapter);
4605
4608
  const selection = inject(Selection);
4606
4609
  const dropdownRef = createRef();
4607
4610
  const subscription = props.component.focus.subscribe((b) => {
@@ -4642,11 +4645,7 @@ function AtComponentView(props) {
4642
4645
  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] }));
4643
4646
  }
4644
4647
  if (readonly() || output()) {
4645
- return (jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4646
- return createVNode('span', {
4647
- class: 'xnote-at-input'
4648
- }, children);
4649
- })] }));
4648
+ 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" })] }));
4650
4649
  }
4651
4650
  const members = props.component.members();
4652
4651
  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) => {
@@ -4662,11 +4661,7 @@ function AtComponentView(props) {
4662
4661
  selection.selectComponentEnd(props.component);
4663
4662
  }, 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 }) :
4664
4663
  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));
4665
- }) }), children: [jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4666
- return createVNode('span', {
4667
- class: 'xnote-at-input'
4668
- }, children);
4669
- })] }) }));
4664
+ }) }), children: [jsx("span", { children: "@" }), slot && jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
4670
4665
  };
4671
4666
  }
4672
4667
  const atComponentLoader = {
@@ -4719,7 +4714,6 @@ class RootComponent extends Component {
4719
4714
  RootComponent.componentName = 'RootComponent';
4720
4715
  RootComponent.type = ContentType.BlockComponent;
4721
4716
  function RootView(props) {
4722
- const adapter = inject(DomAdapter);
4723
4717
  const { content } = props.component.state;
4724
4718
  const ref = createDynamicRef(node => {
4725
4719
  const sub = props.component.onCompositionStart.subscribe(() => {
@@ -4736,12 +4730,7 @@ function RootView(props) {
4736
4730
  const output = useOutput();
4737
4731
  return () => {
4738
4732
  const { rootRef } = props;
4739
- return (jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-comopnent": props.component.name, children: adapter.slotRender(content, children => {
4740
- return (createVNode('div', {
4741
- class: 'xnote-content',
4742
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4743
- }, children));
4744
- }, readonly() || output()) }));
4733
+ 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() }) }));
4745
4734
  };
4746
4735
  }
4747
4736
  const rootComponentLoader = {
@@ -5258,6 +5247,7 @@ function SelectionMask(props) {
5258
5247
  });
5259
5248
  }
5260
5249
 
5250
+ // import { SlotRender } from '../SlotRender'
5261
5251
  const TableComponentView = withAnnotation({
5262
5252
  providers: [TableService]
5263
5253
  }, function TableComponentView(props) {
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);
@@ -702,6 +714,23 @@ function useBlockContent(slot) {
702
714
  });
703
715
  }
704
716
 
717
+ function SlotRender(props) {
718
+ const adaper = core.inject(platformBrowser.DomAdapter);
719
+ const instance = core.getCurrentInstance();
720
+ const sub = props.slot.__changeMarker__.onChange.subscribe(() => {
721
+ instance.markAsDirtied();
722
+ });
723
+ core.onUnmounted(() => {
724
+ sub.unsubscribe();
725
+ });
726
+ return () => {
727
+ const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
728
+ return adaper.slotRender(slot, children => {
729
+ return core$1.createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
730
+ }, renderEnv);
731
+ };
732
+ }
733
+
705
734
  class BlockquoteComponent extends core$1.Component {
706
735
  static fromJSON(textbus, json) {
707
736
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
@@ -795,14 +824,11 @@ function registerBlockquoteShortcut(textbus) {
795
824
  });
796
825
  }
797
826
  function BlockquoteView(props) {
798
- const adapter = core.inject(platformBrowser.DomAdapter);
799
827
  const readonly = useReadonly();
800
828
  const output = useOutput();
801
829
  return () => {
802
830
  const slot = props.component.state.slot;
803
- return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
804
- return core$1.createVNode('div', null, children);
805
- }, readonly() || output()) }));
831
+ return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
806
832
  };
807
833
  }
808
834
  const blockquoteComponentLoader = {
@@ -850,7 +876,6 @@ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '
850
876
  HighlightBoxComponent.componentName = 'HighlightBoxComponent';
851
877
  HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
852
878
  function HighlightBoxView(props) {
853
- const adapter = core.inject(platformBrowser.DomAdapter);
854
879
  const readonly = useReadonly();
855
880
  const output = useOutput();
856
881
  const emoji = [];
@@ -866,22 +891,14 @@ function HighlightBoxView(props) {
866
891
  return () => {
867
892
  const { state, name } = props.component;
868
893
  if (readonly() || output()) {
869
- 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 => {
870
- return core$1.createVNode('div', {
871
- class: 'xnote-highlight-box-content'
872
- }, children);
873
- }, readonly() || output())] }));
894
+ 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() })] }));
874
895
  }
875
896
  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 => {
876
897
  return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
877
898
  }), jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
878
899
  const icon = String.fromCodePoint(i);
879
900
  return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
880
- })] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
881
- return core$1.createVNode('div', {
882
- class: 'xnote-highlight-box-content'
883
- }, children);
884
- }, readonly() || output())] }));
901
+ })] }), 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() })] }));
885
902
  };
886
903
  }
887
904
  const highlightBoxComponentLoader = {
@@ -949,14 +966,11 @@ class ParagraphComponent extends core$1.Component {
949
966
  ParagraphComponent.componentName = 'ParagraphComponent';
950
967
  ParagraphComponent.type = core$1.ContentType.BlockComponent;
951
968
  function ParagraphView(props) {
952
- const adapter = core.inject(platformBrowser.DomAdapter);
953
969
  const readonly = useReadonly();
954
970
  const output = useOutput();
955
971
  return () => {
956
972
  const slot = props.component.state.slot;
957
- return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: adapter.slotRender(slot, children => {
958
- return (core$1.createVNode('div', null, children));
959
- }, readonly() || output()) }));
973
+ return (jsxRuntime.jsx(SlotRender, { tag: 'div', slot: slot, class: "xnote-paragraph", elRef: props.rootRef, "data-component": ParagraphComponent.componentName, renderEnv: readonly() || output() }));
960
974
  };
961
975
  }
962
976
  const paragraphComponentLoader = {
@@ -2108,7 +2122,6 @@ TodolistComponent.zenCoding = {
2108
2122
  }
2109
2123
  };
2110
2124
  function TodolistView(props) {
2111
- const adapter = core.inject(platformBrowser.DomAdapter);
2112
2125
  const component = props.component;
2113
2126
  const state = component.state;
2114
2127
  function toggle() {
@@ -2137,11 +2150,7 @@ function TodolistView(props) {
2137
2150
  marginLeft: indent * 24 + 'px',
2138
2151
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2139
2152
  textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
2140
- }, 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 => {
2141
- return core$1.createVNode('div', {
2142
- class: 'xnote-todolist-content'
2143
- }, children);
2144
- }, readonly() || output())] }));
2153
+ }, 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() })] }));
2145
2154
  };
2146
2155
  }
2147
2156
  const todolistComponentLoader = {
@@ -2341,7 +2350,6 @@ function numberToLetter(num) {
2341
2350
  }).join('');
2342
2351
  }
2343
2352
  function ListComponentView(props) {
2344
- const adapter = core.inject(platformBrowser.DomAdapter);
2345
2353
  const component = props.component;
2346
2354
  function reorder(is) {
2347
2355
  component.state.reorder = is;
@@ -2415,11 +2423,7 @@ function ListComponentView(props) {
2415
2423
  }, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2416
2424
  jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
2417
2425
  :
2418
- 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 => {
2419
- return core$1.createVNode('div', {
2420
- class: 'xnote-list-content'
2421
- }, children);
2422
- }, readonly() || output())] }) }));
2426
+ 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() })] }) }));
2423
2427
  };
2424
2428
  }
2425
2429
  const listComponentLoader = {
@@ -4603,7 +4607,6 @@ AtComponent.componentName = 'AtComponent';
4603
4607
  AtComponent.type = core$1.ContentType.InlineComponent;
4604
4608
 
4605
4609
  function AtComponentView(props) {
4606
- const adapter = core.inject(platformBrowser.DomAdapter);
4607
4610
  const selection = core.inject(core$1.Selection);
4608
4611
  const dropdownRef = core.createRef();
4609
4612
  const subscription = props.component.focus.subscribe((b) => {
@@ -4644,11 +4647,7 @@ function AtComponentView(props) {
4644
4647
  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] }));
4645
4648
  }
4646
4649
  if (readonly() || output()) {
4647
- 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 => {
4648
- return core$1.createVNode('span', {
4649
- class: 'xnote-at-input'
4650
- }, children);
4651
- })] }));
4650
+ 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" })] }));
4652
4651
  }
4653
4652
  const members = props.component.members();
4654
4653
  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) => {
@@ -4664,11 +4663,7 @@ function AtComponentView(props) {
4664
4663
  selection.selectComponentEnd(props.component);
4665
4664
  }, 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 }) :
4666
4665
  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));
4667
- }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4668
- return core$1.createVNode('span', {
4669
- class: 'xnote-at-input'
4670
- }, children);
4671
- })] }) }));
4666
+ }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
4672
4667
  };
4673
4668
  }
4674
4669
  const atComponentLoader = {
@@ -4721,7 +4716,6 @@ class RootComponent extends core$1.Component {
4721
4716
  RootComponent.componentName = 'RootComponent';
4722
4717
  RootComponent.type = core$1.ContentType.BlockComponent;
4723
4718
  function RootView(props) {
4724
- const adapter = core.inject(platformBrowser.DomAdapter);
4725
4719
  const { content } = props.component.state;
4726
4720
  const ref = core.createDynamicRef(node => {
4727
4721
  const sub = props.component.onCompositionStart.subscribe(() => {
@@ -4738,12 +4732,7 @@ function RootView(props) {
4738
4732
  const output = useOutput();
4739
4733
  return () => {
4740
4734
  const { rootRef } = props;
4741
- return (jsxRuntime.jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-comopnent": props.component.name, children: adapter.slotRender(content, children => {
4742
- return (core$1.createVNode('div', {
4743
- class: 'xnote-content',
4744
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4745
- }, children));
4746
- }, readonly() || output()) }));
4735
+ 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() }) }));
4747
4736
  };
4748
4737
  }
4749
4738
  const rootComponentLoader = {
@@ -5260,6 +5249,7 @@ function SelectionMask(props) {
5260
5249
  });
5261
5250
  }
5262
5251
 
5252
+ // import { SlotRender } from '../SlotRender'
5263
5253
  const TableComponentView = core.withAnnotation({
5264
5254
  providers: [TableService]
5265
5255
  }, function TableComponentView(props) {
@@ -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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.0.1-alpha.35",
3
+ "version": "0.0.1-alpha.37",
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",