@textbus/xnote 0.3.5 → 0.3.6

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,11 +1,10 @@
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, getCurrentInstance, createRef, InjectionToken, withAnnotation, onUpdated, onMounted, onPropsChanged, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, Fragment as Fragment$1, Context, watch } from '@viewfly/core';
4
- import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, createVNode, merge, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, onParentSlotUpdated, Textbus, History, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, delay, tap, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
3
+ import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, getCurrentInstance, createRef, InjectionToken, withAnnotation, onUpdated, onMounted, watch, reactive, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, Fragment as Fragment$1, createContext } from '@viewfly/core';
4
+ import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, createVNode, merge, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDetach, onGetRanges, onParentSlotUpdated, Textbus, History, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, delay, tap, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
5
5
  import { normalizeHex, hex2Hsl, hex2Rgb, hex2Hsv, hsl2Hex, hsl2Hsv, hsl2Rgb, rgb2Hsl, rgb2Hex, rgb2Hsv, hsv2Hex, hsv2Hsl, hsv2Rgb, any2Hsl, parseCss } from '@tanbo/color';
6
6
  import { VIEW_CONTAINER, isMac, DomAdapter, Input, BrowserModule, SelectionBridge, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, CollaborateCursor, Parser } from '@textbus/platform-browser';
7
7
  import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
8
- import { useProduce } from '@viewfly/hooks';
9
8
  import highlightjs from 'highlight.js';
10
9
  import { v4 } from 'uuid';
11
10
  import Katex from 'katex';
@@ -1164,7 +1163,7 @@ function useBlockContent(slot) {
1164
1163
  const selection = textbus.get(Selection);
1165
1164
  onBreak(ev => {
1166
1165
  if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
1167
- const p = new ParagraphComponent(textbus);
1166
+ const p = new ParagraphComponent();
1168
1167
  ev.target.insert(p);
1169
1168
  selection.setPosition(p.state.slot, 0);
1170
1169
  ev.preventDefault();
@@ -1173,7 +1172,7 @@ function useBlockContent(slot) {
1173
1172
  onContentInsert(ev => {
1174
1173
  if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
1175
1174
  (typeof ev.data.content === 'string' || ev.data.content.type !== ContentType.BlockComponent)) {
1176
- const p = new ParagraphComponent(textbus);
1175
+ const p = new ParagraphComponent();
1177
1176
  const childSlot = p.state.slot;
1178
1177
  childSlot.insert(ev.data.content);
1179
1178
  ev.target.insert(p);
@@ -1195,10 +1194,12 @@ function SlotRender(props) {
1195
1194
  });
1196
1195
  }
1197
1196
  let sub = listen(slot);
1198
- onPropsChanged((currentProps, oldProps) => {
1199
- if (oldProps.slot !== currentProps.slot) {
1197
+ watch(() => {
1198
+ return props.slot;
1199
+ }, (currentSlot, oldSlot) => {
1200
+ if (oldSlot !== currentSlot) {
1200
1201
  sub.unsubscribe();
1201
- sub = listen(currentProps.slot);
1202
+ sub = listen(currentSlot);
1202
1203
  }
1203
1204
  });
1204
1205
  onUnmounted(() => {
@@ -1215,16 +1216,16 @@ function SlotRender(props) {
1215
1216
  class BlockquoteComponent extends Component {
1216
1217
  static fromJSON(textbus, json) {
1217
1218
  const slot = textbus.get(Registry).createSlot(json.slot);
1218
- return new BlockquoteComponent(textbus, {
1219
+ return new BlockquoteComponent({
1219
1220
  slot
1220
1221
  });
1221
1222
  }
1222
- constructor(textbus, state = {
1223
+ constructor(state = {
1223
1224
  slot: new Slot([
1224
1225
  ContentType.BlockComponent
1225
1226
  ])
1226
1227
  }) {
1227
- super(textbus, state);
1228
+ super(state);
1228
1229
  }
1229
1230
  getSlots() {
1230
1231
  return [this.state.slot];
@@ -1289,7 +1290,7 @@ function toBlockquote(textbus) {
1289
1290
  });
1290
1291
  }
1291
1292
  else {
1292
- const block = new BlockquoteComponent(textbus);
1293
+ const block = new BlockquoteComponent();
1293
1294
  const slot = block.state.slot;
1294
1295
  if (selection.startSlot === selection.endSlot) {
1295
1296
  const parentComponent = selection.startSlot.parent;
@@ -1334,7 +1335,7 @@ const blockquoteComponentLoader = {
1334
1335
  match(element, returnableContentTypes) {
1335
1336
  return returnableContentTypes.includes(ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
1336
1337
  },
1337
- read(element, textbus, slotParser) {
1338
+ read(element, _, slotParser) {
1338
1339
  const delta = slotParser(new Slot([
1339
1340
  ContentType.BlockComponent,
1340
1341
  ContentType.InlineComponent,
@@ -1343,10 +1344,10 @@ const blockquoteComponentLoader = {
1343
1344
  const slot = new Slot([
1344
1345
  ContentType.BlockComponent,
1345
1346
  ]);
1346
- deltaToBlock(delta, textbus).forEach(i => {
1347
+ deltaToBlock(delta).forEach(i => {
1347
1348
  slot.insert(i);
1348
1349
  });
1349
- return new BlockquoteComponent(textbus, {
1350
+ return new BlockquoteComponent({
1350
1351
  slot
1351
1352
  });
1352
1353
  },
@@ -1354,18 +1355,18 @@ const blockquoteComponentLoader = {
1354
1355
 
1355
1356
  class HighlightBoxComponent extends Component {
1356
1357
  static fromJSON(textbus, json) {
1357
- return new HighlightBoxComponent(textbus, {
1358
+ return new HighlightBoxComponent({
1358
1359
  type: json.type,
1359
1360
  slot: textbus.get(Registry).createSlot(json.slot)
1360
1361
  });
1361
1362
  }
1362
- constructor(textbus, state = {
1363
+ constructor(state = {
1363
1364
  type: '',
1364
1365
  slot: new Slot([
1365
1366
  ContentType.BlockComponent,
1366
1367
  ])
1367
1368
  }) {
1368
- super(textbus, state);
1369
+ super(state);
1369
1370
  }
1370
1371
  getSlots() {
1371
1372
  return [this.state.slot];
@@ -1431,10 +1432,10 @@ const highlightBoxComponentLoader = {
1431
1432
  const slot = new Slot([
1432
1433
  ContentType.BlockComponent,
1433
1434
  ]);
1434
- deltaToBlock(delta, textbus).forEach(i => {
1435
+ deltaToBlock(delta).forEach(i => {
1435
1436
  slot.insert(i);
1436
1437
  });
1437
- return new HighlightBoxComponent(textbus, {
1438
+ return new HighlightBoxComponent({
1438
1439
  type: element.dataset.icon || '',
1439
1440
  slot
1440
1441
  });
@@ -1529,11 +1530,11 @@ const colorFormatLoader = {
1529
1530
  }
1530
1531
  };
1531
1532
 
1532
- function createTimelineItem(textbus, theme) {
1533
+ function createTimelineItem(theme) {
1533
1534
  const slot = new Slot([
1534
1535
  ContentType.BlockComponent,
1535
1536
  ]);
1536
- const title = new ParagraphComponent(textbus);
1537
+ const title = new ParagraphComponent();
1537
1538
  title.state.slot.insert('时间主题', [
1538
1539
  [fontSizeFormatter, '18px'],
1539
1540
  [boldFormatter, true]
@@ -1542,7 +1543,7 @@ function createTimelineItem(textbus, theme) {
1542
1543
  [fontSizeFormatter, '15px'],
1543
1544
  [colorFormatter, '#777']
1544
1545
  ]);
1545
- const desc = new ParagraphComponent(textbus);
1546
+ const desc = new ParagraphComponent();
1546
1547
  desc.state.slot.insert('描述信息...');
1547
1548
  slot.insert(title);
1548
1549
  slot.insert(desc);
@@ -1551,7 +1552,7 @@ function createTimelineItem(textbus, theme) {
1551
1552
  class TimelineComponent extends Component {
1552
1553
  static fromJSON(textbus, json) {
1553
1554
  const registry = textbus.get(Registry);
1554
- return new TimelineComponent(textbus, {
1555
+ return new TimelineComponent({
1555
1556
  items: json.items.map(i => {
1556
1557
  return {
1557
1558
  theme: i.theme,
@@ -1585,16 +1586,16 @@ Object.defineProperty(TimelineComponent, "type", {
1585
1586
  value: ContentType.BlockComponent
1586
1587
  });
1587
1588
 
1588
- function createStepItem(textbus) {
1589
+ function createStepItem() {
1589
1590
  const slot = new Slot([
1590
1591
  ContentType.BlockComponent
1591
1592
  ]);
1592
- const title = new ParagraphComponent(textbus);
1593
+ const title = new ParagraphComponent();
1593
1594
  title.state.slot.insert('标题', [
1594
1595
  [fontSizeFormatter, '18px'],
1595
1596
  [boldFormatter, true]
1596
1597
  ]);
1597
- const content = new ParagraphComponent(textbus);
1598
+ const content = new ParagraphComponent();
1598
1599
  content.state.slot.insert('描述信息...');
1599
1600
  slot.insert(title);
1600
1601
  slot.insert(content);
@@ -1603,7 +1604,7 @@ function createStepItem(textbus) {
1603
1604
  class StepComponent extends Component {
1604
1605
  static fromJSON(textbus, json) {
1605
1606
  const registry = textbus.get(Registry);
1606
- return new StepComponent(textbus, {
1607
+ return new StepComponent({
1607
1608
  step: json.step,
1608
1609
  items: json.items.map(i => {
1609
1610
  return {
@@ -1643,17 +1644,17 @@ Object.defineProperty(StepComponent, "type", {
1643
1644
  class ParagraphComponent extends Component {
1644
1645
  static fromJSON(textbus, json) {
1645
1646
  const slot = textbus.get(Registry).createSlot(json.slot);
1646
- return new ParagraphComponent(textbus, {
1647
+ return new ParagraphComponent({
1647
1648
  slot
1648
1649
  });
1649
1650
  }
1650
- constructor(textbus, state = {
1651
+ constructor(state = {
1651
1652
  slot: new Slot([
1652
1653
  ContentType.InlineComponent,
1653
1654
  ContentType.Text
1654
1655
  ])
1655
1656
  }) {
1656
- super(textbus, state);
1657
+ super(state);
1657
1658
  }
1658
1659
  getSlots() {
1659
1660
  return [this.state.slot];
@@ -1666,7 +1667,7 @@ class ParagraphComponent extends Component {
1666
1667
  const isEmpty = this.state.slot.isEmpty;
1667
1668
  const afterSlot = ev.target.cut(ev.data.index);
1668
1669
  afterSlot.removeAttribute(headingAttr);
1669
- const nextParagraph = new ParagraphComponent(injector, {
1670
+ const nextParagraph = new ParagraphComponent({
1670
1671
  slot: afterSlot
1671
1672
  });
1672
1673
  if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
@@ -1709,7 +1710,7 @@ const paragraphComponentLoader = {
1709
1710
  return returnableContentTypes.includes(ContentType.BlockComponent) &&
1710
1711
  (element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
1711
1712
  },
1712
- read(element, textbus, slotParser) {
1713
+ read(element, _, slotParser) {
1713
1714
  let content;
1714
1715
  if (/^P|H[1-6]$/.test(element.tagName)) {
1715
1716
  content = element;
@@ -1727,7 +1728,7 @@ const paragraphComponentLoader = {
1727
1728
  ContentType.InlineComponent,
1728
1729
  ContentType.BlockComponent
1729
1730
  ]), content).toDelta();
1730
- const results = deltaToBlock(delta, textbus);
1731
+ const results = deltaToBlock(delta);
1731
1732
  if (results.length === 1) {
1732
1733
  return results[0];
1733
1734
  }
@@ -1740,7 +1741,7 @@ const paragraphComponentLoader = {
1740
1741
  return containerSlot;
1741
1742
  }
1742
1743
  };
1743
- function deltaToBlock(delta, textbus) {
1744
+ function deltaToBlock(delta) {
1744
1745
  const results = [];
1745
1746
  let slot = null;
1746
1747
  for (const item of delta) {
@@ -1753,7 +1754,7 @@ function deltaToBlock(delta, textbus) {
1753
1754
  delta.attributes.forEach((value, key) => {
1754
1755
  slot.setAttribute(key, value);
1755
1756
  });
1756
- results.push(new ParagraphComponent(textbus, {
1757
+ results.push(new ParagraphComponent({
1757
1758
  slot
1758
1759
  }));
1759
1760
  }
@@ -1918,7 +1919,7 @@ class SourceCodeComponent extends Component {
1918
1919
  }
1919
1920
  static fromJSON(textbus, json) {
1920
1921
  const registry = textbus.get(Registry);
1921
- return new SourceCodeComponent(textbus, {
1922
+ return new SourceCodeComponent({
1922
1923
  slots: json.slots.map(item => {
1923
1924
  return {
1924
1925
  slot: registry.createSlot(item.slot),
@@ -1948,7 +1949,7 @@ class SourceCodeComponent extends Component {
1948
1949
  ContentType.InlineComponent,
1949
1950
  ContentType.Text
1950
1951
  ]);
1951
- const paragraph = new ParagraphComponent(textbus, {
1952
+ const paragraph = new ParagraphComponent({
1952
1953
  slot
1953
1954
  });
1954
1955
  const index = parentSlot.indexOf(parentComponent);
@@ -2323,7 +2324,7 @@ const sourceCodeComponentLoader = {
2323
2324
  ((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
2324
2325
  element.tagName === 'PRE');
2325
2326
  },
2326
- read(el, textbus) {
2327
+ read(el) {
2327
2328
  let slots = [];
2328
2329
  if (el.tagName === 'DIV') {
2329
2330
  const lines = el.querySelectorAll('.xnote-source-code-line');
@@ -2346,7 +2347,7 @@ const sourceCodeComponentLoader = {
2346
2347
  return item;
2347
2348
  });
2348
2349
  }
2349
- return new SourceCodeComponent(textbus, {
2350
+ return new SourceCodeComponent({
2350
2351
  lang: el.dataset.lang || '',
2351
2352
  theme: el.dataset.theme || '',
2352
2353
  lineNumber: el.dataset.lineNumber === 'true',
@@ -2441,7 +2442,7 @@ function registerTextIndentShortcut(textbus) {
2441
2442
 
2442
2443
  class ImageComponent extends Component {
2443
2444
  static fromJSON(textbus, json) {
2444
- return new ImageComponent(textbus, Object.assign({}, json));
2445
+ return new ImageComponent(Object.assign({}, json));
2445
2446
  }
2446
2447
  getSlots() {
2447
2448
  return [];
@@ -2481,9 +2482,9 @@ const imageComponentLoader = {
2481
2482
  match(element) {
2482
2483
  return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2483
2484
  },
2484
- read(element, textbus) {
2485
+ read(element) {
2485
2486
  const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2486
- return new ImageComponent(textbus, {
2487
+ return new ImageComponent({
2487
2488
  src: img.src,
2488
2489
  width: img.style.width || 'auto',
2489
2490
  height: img.style.height || 'auto'
@@ -2492,8 +2493,8 @@ const imageComponentLoader = {
2492
2493
  };
2493
2494
 
2494
2495
  class VideoComponent extends Component {
2495
- static fromJSON(textbus, json) {
2496
- return new VideoComponent(textbus, Object.assign({}, json));
2496
+ static fromJSON(_, json) {
2497
+ return new VideoComponent(Object.assign({}, json));
2497
2498
  }
2498
2499
  getSlots() {
2499
2500
  return [];
@@ -2533,9 +2534,9 @@ const videoComponentLoader = {
2533
2534
  match(element) {
2534
2535
  return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2535
2536
  },
2536
- read(element, textbus) {
2537
+ read(element) {
2537
2538
  const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2538
- return new VideoComponent(textbus, {
2539
+ return new VideoComponent({
2539
2540
  src: video.src,
2540
2541
  width: video.style.width || 'auto',
2541
2542
  height: video.style.height || 'auto'
@@ -2545,18 +2546,6 @@ const videoComponentLoader = {
2545
2546
 
2546
2547
  let ToolService = class ToolService {
2547
2548
  constructor(selection, controller) {
2548
- Object.defineProperty(this, "selection", {
2549
- enumerable: true,
2550
- configurable: true,
2551
- writable: true,
2552
- value: selection
2553
- });
2554
- Object.defineProperty(this, "controller", {
2555
- enumerable: true,
2556
- configurable: true,
2557
- writable: true,
2558
- value: controller
2559
- });
2560
2549
  Object.defineProperty(this, "state", {
2561
2550
  enumerable: true,
2562
2551
  configurable: true,
@@ -2569,12 +2558,11 @@ let ToolService = class ToolService {
2569
2558
  writable: true,
2570
2559
  value: void 0
2571
2560
  });
2572
- const [state, updateState] = useProduce({
2561
+ this.state = createSignal({
2573
2562
  inSourceCode: false,
2574
2563
  readonly: controller.readonly,
2575
2564
  selectEmbed: false,
2576
2565
  });
2577
- this.state = state;
2578
2566
  this.sub = merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2579
2567
  const { startSlot, endSlot, startOffset, endOffset } = selection;
2580
2568
  let is = false;
@@ -2584,10 +2572,10 @@ let ToolService = class ToolService {
2584
2572
  is = true;
2585
2573
  }
2586
2574
  }
2587
- updateState(draft => {
2588
- draft.selectEmbed = is;
2589
- draft.readonly = controller.readonly;
2590
- draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
2575
+ this.state.set({
2576
+ selectEmbed: is,
2577
+ readonly: controller.readonly,
2578
+ inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
2591
2579
  });
2592
2580
  });
2593
2581
  }
@@ -2611,7 +2599,7 @@ function AttrTool(props) {
2611
2599
  const selection = inject(Selection);
2612
2600
  const query = inject(Query);
2613
2601
  const refreshService = inject(RefreshService);
2614
- const [checkStates, setCheckStates] = useProduce({
2602
+ const checkStates = reactive({
2615
2603
  textAlign: 'left',
2616
2604
  textIndent: 0
2617
2605
  });
@@ -2619,23 +2607,21 @@ function AttrTool(props) {
2619
2607
  if (!props.slot && !selection.isSelected) {
2620
2608
  return;
2621
2609
  }
2622
- setCheckStates(draft => {
2623
- const range = props.slot ? {
2624
- startSlot: props.slot,
2625
- endSlot: props.slot,
2626
- startOffset: 0,
2627
- endOffset: props.slot.length
2628
- } : {
2629
- startSlot: selection.startSlot,
2630
- startOffset: selection.startOffset,
2631
- endSlot: selection.endSlot,
2632
- endOffset: selection.endOffset
2633
- };
2634
- const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
2635
- const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
2636
- draft.textAlign = textAlignState.state === QueryStateType.Enabled ? textAlignState.value : 'left';
2637
- draft.textIndent = textIndentState.state === QueryStateType.Enabled ? textIndentState.value : 0;
2638
- });
2610
+ const range = props.slot ? {
2611
+ startSlot: props.slot,
2612
+ endSlot: props.slot,
2613
+ startOffset: 0,
2614
+ endOffset: props.slot.length
2615
+ } : {
2616
+ startSlot: selection.startSlot,
2617
+ startOffset: selection.startOffset,
2618
+ endSlot: selection.endSlot,
2619
+ endOffset: selection.endOffset
2620
+ };
2621
+ const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
2622
+ const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
2623
+ checkStates.textAlign = textAlignState.state === QueryStateType.Enabled ? textAlignState.value : 'left';
2624
+ checkStates.textIndent = textIndentState.state === QueryStateType.Enabled ? textIndentState.value : 0;
2639
2625
  }
2640
2626
  updateCheckStates();
2641
2627
  const subscription = refreshService.onRefresh.subscribe(() => {
@@ -2684,20 +2670,19 @@ function AttrTool(props) {
2684
2670
  }
2685
2671
  const commonState = useCommonState();
2686
2672
  return withScopedCSS(scopedId$e, () => {
2687
- const states = checkStates();
2688
2673
  const b = commonState().inSourceCode || commonState().readonly;
2689
2674
  return (jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
2690
2675
  {
2691
- label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
2676
+ label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: checkStates.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
2692
2677
  value: 't-l'
2693
2678
  }, {
2694
- label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
2679
+ label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked: checkStates.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
2695
2680
  value: 't-r'
2696
2681
  }, {
2697
- label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
2682
+ label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked: checkStates.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
2698
2683
  value: 't-c'
2699
2684
  }, {
2700
- label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
2685
+ label: jsx(MenuItem, { icon: jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked: checkStates.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
2701
2686
  value: 't-j'
2702
2687
  }, {
2703
2688
  label: jsx(Divider, {}),
@@ -2709,7 +2694,7 @@ function AttrTool(props) {
2709
2694
  label: jsx(MenuItem, { desc: jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
2710
2695
  value: 'i-'
2711
2696
  }
2712
- ], children: props.children || jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
2697
+ ], children: props.children || jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsx("span", { class: `xnote-icon-paragraph-${checkStates.textAlign || 'left'} icon` }) }) }));
2713
2698
  });
2714
2699
  }
2715
2700
 
@@ -2824,7 +2809,7 @@ const defaultColumnWidth = 100;
2824
2809
  class TableComponent extends Component {
2825
2810
  static fromJSON(textbus, json) {
2826
2811
  const registry = textbus.get(Registry);
2827
- return new TableComponent(textbus, {
2812
+ return new TableComponent({
2828
2813
  columnsConfig: json.columnsConfig || [],
2829
2814
  mergeConfig: json.mergeConfig || [],
2830
2815
  rows: json.rows.map(row => {
@@ -2840,14 +2825,14 @@ class TableComponent extends Component {
2840
2825
  })
2841
2826
  });
2842
2827
  }
2843
- constructor(textbus, state = {
2828
+ constructor(state = {
2844
2829
  columnsConfig: Array.from({ length: 5 }).fill(defaultColumnWidth),
2845
2830
  mergeConfig: {},
2846
2831
  rows: Array.from({ length: 3 }).map(() => {
2847
2832
  return {
2848
2833
  height: defaultRowHeight,
2849
2834
  cells: Array.from({ length: 5 }).map(() => {
2850
- const p = new ParagraphComponent(textbus);
2835
+ const p = new ParagraphComponent();
2851
2836
  const slot = new Slot([ContentType.BlockComponent]);
2852
2837
  slot.insert(p);
2853
2838
  return {
@@ -2858,18 +2843,18 @@ class TableComponent extends Component {
2858
2843
  };
2859
2844
  })
2860
2845
  }) {
2861
- super(textbus, state);
2846
+ super(state);
2862
2847
  Object.defineProperty(this, "selection", {
2863
2848
  enumerable: true,
2864
2849
  configurable: true,
2865
2850
  writable: true,
2866
- value: this.textbus.get(Selection)
2851
+ value: void 0
2867
2852
  });
2868
2853
  Object.defineProperty(this, "commander", {
2869
2854
  enumerable: true,
2870
2855
  configurable: true,
2871
2856
  writable: true,
2872
- value: this.textbus.get(Commander)
2857
+ value: void 0
2873
2858
  });
2874
2859
  Object.defineProperty(this, "focus", {
2875
2860
  enumerable: true,
@@ -3134,6 +3119,8 @@ class TableComponent extends Component {
3134
3119
  }
3135
3120
  setup() {
3136
3121
  const selection = useContext(Selection);
3122
+ this.selection = selection;
3123
+ this.commander = useContext(Commander);
3137
3124
  onFocusIn(() => {
3138
3125
  this.focus.next(true);
3139
3126
  });
@@ -3151,7 +3138,7 @@ class TableComponent extends Component {
3151
3138
  this.tableSelection.set(null);
3152
3139
  }
3153
3140
  });
3154
- onDestroy(() => {
3141
+ onDetach(() => {
3155
3142
  sub.unsubscribe();
3156
3143
  });
3157
3144
  onGetRanges(ev => {
@@ -3261,7 +3248,7 @@ class TableComponent extends Component {
3261
3248
  const slot = new Slot([
3262
3249
  ContentType.BlockComponent,
3263
3250
  ]);
3264
- slot.insert(new ParagraphComponent(this.textbus, {
3251
+ slot.insert(new ParagraphComponent({
3265
3252
  slot: new Slot([
3266
3253
  ContentType.InlineComponent,
3267
3254
  ContentType.Text
@@ -3286,7 +3273,7 @@ class TableComponent extends Component {
3286
3273
  const slot = new Slot([
3287
3274
  ContentType.BlockComponent,
3288
3275
  ]);
3289
- slot.insert(new ParagraphComponent(this.textbus, {
3276
+ slot.insert(new ParagraphComponent({
3290
3277
  slot: new Slot([
3291
3278
  ContentType.InlineComponent,
3292
3279
  ContentType.Text
@@ -3367,7 +3354,7 @@ const strikeThroughFormatLoader = {
3367
3354
  class TodolistComponent extends Component {
3368
3355
  static fromJSON(textbus, json) {
3369
3356
  const slot = textbus.get(Registry).createSlot(json.slot);
3370
- return new TodolistComponent(textbus, {
3357
+ return new TodolistComponent({
3371
3358
  slot,
3372
3359
  checked: json.checked
3373
3360
  });
@@ -3376,7 +3363,6 @@ class TodolistComponent extends Component {
3376
3363
  return [this.state.slot];
3377
3364
  }
3378
3365
  setup() {
3379
- const textbus = useContext();
3380
3366
  const commander = useContext(Commander);
3381
3367
  const selection = useContext(Selection);
3382
3368
  onBreak(ev => {
@@ -3386,7 +3372,7 @@ class TodolistComponent extends Component {
3386
3372
  const beforeIndex = this.parent.indexOf(this);
3387
3373
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3388
3374
  if (beforeComponent instanceof TodolistComponent) {
3389
- const nextComponent = new ParagraphComponent(textbus, {
3375
+ const nextComponent = new ParagraphComponent({
3390
3376
  slot: new Slot([
3391
3377
  ContentType.Text,
3392
3378
  ContentType.InlineComponent
@@ -3400,7 +3386,7 @@ class TodolistComponent extends Component {
3400
3386
  return;
3401
3387
  }
3402
3388
  }
3403
- const nextParagraph = new TodolistComponent(textbus, {
3389
+ const nextParagraph = new TodolistComponent({
3404
3390
  checked: this.state.checked,
3405
3391
  slot
3406
3392
  });
@@ -3417,7 +3403,7 @@ class TodolistComponent extends Component {
3417
3403
  return false;
3418
3404
  }
3419
3405
  const slot = selection.commonAncestorSlot.cut();
3420
- const paragraph = new ParagraphComponent(textbus, {
3406
+ const paragraph = new ParagraphComponent({
3421
3407
  slot
3422
3408
  });
3423
3409
  commander.replaceComponent(this, paragraph);
@@ -3505,12 +3491,12 @@ const todolistComponentLoader = {
3505
3491
  match(element) {
3506
3492
  return element.dataset.component === TodolistComponent.componentName;
3507
3493
  },
3508
- read(element, injector, slotParser) {
3494
+ read(element, _, slotParser) {
3509
3495
  const slot = slotParser(new Slot([
3510
3496
  ContentType.Text,
3511
3497
  ContentType.InlineComponent
3512
3498
  ]), element.children[1]);
3513
- return new TodolistComponent(injector, {
3499
+ return new TodolistComponent({
3514
3500
  checked: element.children[0].hasAttribute('checked'),
3515
3501
  slot
3516
3502
  });
@@ -3529,7 +3515,7 @@ function toList(textbus, type) {
3529
3515
  },
3530
3516
  stateFactory(slots) {
3531
3517
  return slots.map((slot, index) => {
3532
- return new ListComponent(textbus, {
3518
+ return new ListComponent({
3533
3519
  type,
3534
3520
  reorder: index === 0,
3535
3521
  slot
@@ -3553,7 +3539,7 @@ function registerListShortcut(textbus) {
3553
3539
  }
3554
3540
  class ListComponent extends Component {
3555
3541
  static fromJSON(textbus, json) {
3556
- return new ListComponent(textbus, {
3542
+ return new ListComponent({
3557
3543
  type: json.type,
3558
3544
  reorder: json.reorder,
3559
3545
  slot: textbus.get(Registry).createSlot(json.slot)
@@ -3563,7 +3549,6 @@ class ListComponent extends Component {
3563
3549
  return [this.state.slot];
3564
3550
  }
3565
3551
  setup() {
3566
- const textbus = useContext();
3567
3552
  const commander = useContext(Commander);
3568
3553
  const selection = useContext(Selection);
3569
3554
  const updateAfterList = (ref) => {
@@ -3593,7 +3578,7 @@ class ListComponent extends Component {
3593
3578
  const beforeIndex = this.parent.indexOf(this);
3594
3579
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3595
3580
  if (beforeComponent instanceof ListComponent) {
3596
- const nextComponent = new ParagraphComponent(textbus, {
3581
+ const nextComponent = new ParagraphComponent({
3597
3582
  slot: new Slot([
3598
3583
  ContentType.Text,
3599
3584
  ContentType.InlineComponent
@@ -3608,7 +3593,7 @@ class ListComponent extends Component {
3608
3593
  return;
3609
3594
  }
3610
3595
  }
3611
- const nextList = new ListComponent(textbus, {
3596
+ const nextList = new ListComponent({
3612
3597
  slot,
3613
3598
  reorder: false,
3614
3599
  type: this.state.type
@@ -3627,7 +3612,7 @@ class ListComponent extends Component {
3627
3612
  return false;
3628
3613
  }
3629
3614
  const slot = selection.commonAncestorSlot.cut();
3630
- const paragraph = new ParagraphComponent(textbus, {
3615
+ const paragraph = new ParagraphComponent({
3631
3616
  slot
3632
3617
  });
3633
3618
  commander.replaceComponent(this, paragraph);
@@ -3803,7 +3788,7 @@ const listComponentLoader = {
3803
3788
  ContentType.InlineComponent,
3804
3789
  ContentType.Text
3805
3790
  ]), element.querySelector('.xnote-list-content') || document.createElement('div'));
3806
- return new ListComponent(textbus, {
3791
+ return new ListComponent({
3807
3792
  slot,
3808
3793
  reorder: element.dataset.reorder !== 'false',
3809
3794
  type
@@ -3817,7 +3802,7 @@ const listComponentLoader = {
3817
3802
  ContentType.InlineComponent,
3818
3803
  ContentType.Text
3819
3804
  ]), i);
3820
- const component = new ListComponent(textbus, {
3805
+ const component = new ListComponent({
3821
3806
  slot,
3822
3807
  reorder: index === 0,
3823
3808
  type
@@ -3832,7 +3817,7 @@ function useActiveBlock() {
3832
3817
  const query = inject(Query);
3833
3818
  const selection = inject(Selection);
3834
3819
  const refreshService = inject(RefreshService);
3835
- const [checkStates, setCheckStates] = useProduce({
3820
+ const checkStates = reactive({
3836
3821
  paragraph: false,
3837
3822
  h1: false,
3838
3823
  h2: false,
@@ -3849,22 +3834,20 @@ function useActiveBlock() {
3849
3834
  highlightBox: false
3850
3835
  });
3851
3836
  function updateCheckStates(range) {
3852
- setCheckStates(draft => {
3853
- const heading = query.queryAttributeByRange(headingAttr, range);
3854
- draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === QueryStateType.Enabled;
3855
- draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
3856
- if (heading.state === QueryStateType.Enabled) {
3857
- draft[heading.value] = true;
3858
- draft.paragraph = false;
3859
- }
3860
- const queryList = query.queryComponentByRange(ListComponent, range);
3861
- draft.unorderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
3862
- draft.orderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
3863
- draft.table = query.queryComponentByRange(TableComponent, range).state === QueryStateType.Enabled;
3864
- draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === QueryStateType.Enabled;
3865
- draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === QueryStateType.Enabled;
3866
- draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === QueryStateType.Enabled;
3867
- });
3837
+ const heading = query.queryAttributeByRange(headingAttr, range);
3838
+ checkStates.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === QueryStateType.Enabled;
3839
+ checkStates.h1 = checkStates.h2 = checkStates.h3 = checkStates.h4 = checkStates.h5 = checkStates.h6 = false;
3840
+ if (heading.state === QueryStateType.Enabled) {
3841
+ checkStates[heading.value] = true;
3842
+ checkStates.paragraph = false;
3843
+ }
3844
+ const queryList = query.queryComponentByRange(ListComponent, range);
3845
+ checkStates.unorderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
3846
+ checkStates.orderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
3847
+ checkStates.table = query.queryComponentByRange(TableComponent, range).state === QueryStateType.Enabled;
3848
+ checkStates.todolist = query.queryComponentByRange(TodolistComponent, range).state === QueryStateType.Enabled;
3849
+ checkStates.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === QueryStateType.Enabled;
3850
+ checkStates.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === QueryStateType.Enabled;
3868
3851
  }
3869
3852
  const subscription = refreshService.onRefresh.subscribe(() => {
3870
3853
  if (!selection.isSelected) {
@@ -3897,7 +3880,7 @@ function useActiveBlock() {
3897
3880
  endOffset: selection.endOffset
3898
3881
  });
3899
3882
  }
3900
- return checkStates();
3883
+ return checkStates;
3901
3884
  };
3902
3885
  }
3903
3886
 
@@ -3928,7 +3911,7 @@ function useBlockTransform() {
3928
3911
  ]);
3929
3912
  },
3930
3913
  stateFactory(slots) {
3931
- return slots.map(slot => new ParagraphComponent(textbus, {
3914
+ return slots.map(slot => new ParagraphComponent({
3932
3915
  slot
3933
3916
  }));
3934
3917
  }
@@ -3936,7 +3919,7 @@ function useBlockTransform() {
3936
3919
  break;
3937
3920
  case 'table':
3938
3921
  {
3939
- const table = new TableComponent(textbus);
3922
+ const table = new TableComponent();
3940
3923
  if (((_a = selection.commonAncestorSlot) === null || _a === void 0 ? void 0 : _a.isEmpty) && ((_b = selection.commonAncestorComponent) === null || _b === void 0 ? void 0 : _b.name) === ParagraphComponent.componentName) {
3941
3924
  commander.replaceComponent(selection.commonAncestorComponent, table);
3942
3925
  }
@@ -3957,7 +3940,7 @@ function useBlockTransform() {
3957
3940
  },
3958
3941
  stateFactory(slots) {
3959
3942
  return slots.map(slot => {
3960
- return new TodolistComponent(textbus, {
3943
+ return new TodolistComponent({
3961
3944
  checked: false,
3962
3945
  slot
3963
3946
  });
@@ -3986,7 +3969,7 @@ function useBlockTransform() {
3986
3969
  },
3987
3970
  stateFactory(slots) {
3988
3971
  return slots.map(slot => {
3989
- return new ParagraphComponent(textbus, {
3972
+ return new ParagraphComponent({
3990
3973
  slot
3991
3974
  });
3992
3975
  });
@@ -4002,7 +3985,7 @@ function useBlockTransform() {
4002
3985
  ]);
4003
3986
  },
4004
3987
  stateFactory(slots) {
4005
- return [new SourceCodeComponent(textbus, {
3988
+ return [new SourceCodeComponent({
4006
3989
  lang: '',
4007
3990
  lineNumber: true,
4008
3991
  autoBreak: true,
@@ -4034,7 +4017,7 @@ function useBlockTransform() {
4034
4017
  });
4035
4018
  }
4036
4019
  else {
4037
- const block = new HighlightBoxComponent(textbus);
4020
+ const block = new HighlightBoxComponent();
4038
4021
  const slot = block.state.slot;
4039
4022
  if (selection.startSlot === selection.endSlot) {
4040
4023
  const parentComponent = selection.startSlot.parent;
@@ -4416,7 +4399,7 @@ function BoldTool() {
4416
4399
  const textbus = inject(Textbus);
4417
4400
  const refreshService = inject(RefreshService);
4418
4401
  const commonState = useCommonState();
4419
- const [viewModel, update] = useProduce({
4402
+ const viewModel = reactive({
4420
4403
  highlight: false,
4421
4404
  });
4422
4405
  function toggle() {
@@ -4424,16 +4407,13 @@ function BoldTool() {
4424
4407
  }
4425
4408
  const sub = refreshService.onRefresh.subscribe(() => {
4426
4409
  const state = query.queryFormat(boldFormatter);
4427
- update(draft => {
4428
- draft.highlight = state.state === QueryStateType.Enabled;
4429
- });
4410
+ viewModel.highlight = state.state === QueryStateType.Enabled;
4430
4411
  });
4431
4412
  onUnmounted(() => {
4432
4413
  sub.unsubscribe();
4433
4414
  });
4434
4415
  return () => {
4435
- const vm = viewModel();
4436
- return jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-bold" }) });
4416
+ return jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-bold" }) });
4437
4417
  };
4438
4418
  }
4439
4419
 
@@ -4455,7 +4435,7 @@ function CodeTool() {
4455
4435
  const refreshService = inject(RefreshService);
4456
4436
  const textbus = inject(Textbus);
4457
4437
  const commonState = useCommonState();
4458
- const [viewModel, update] = useProduce({
4438
+ const viewModel = reactive({
4459
4439
  highlight: false,
4460
4440
  });
4461
4441
  function toggle() {
@@ -4463,16 +4443,13 @@ function CodeTool() {
4463
4443
  }
4464
4444
  const sub = refreshService.onRefresh.subscribe(() => {
4465
4445
  const state = query.queryFormat(codeFormatter);
4466
- update(draft => {
4467
- draft.highlight = state.state === QueryStateType.Enabled;
4468
- });
4446
+ viewModel.highlight = state.state === QueryStateType.Enabled;
4469
4447
  });
4470
4448
  onUnmounted(() => {
4471
4449
  sub.unsubscribe();
4472
4450
  });
4473
4451
  return () => {
4474
- const vm = viewModel();
4475
- return jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-code" }) });
4452
+ return jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-code" }) });
4476
4453
  };
4477
4454
  }
4478
4455
 
@@ -4691,7 +4668,7 @@ class KatexEditor extends Textbus {
4691
4668
  }
4692
4669
  mount(host, code) {
4693
4670
  this.host = host;
4694
- const model = new SourceCodeComponent(this, {
4671
+ const model = new SourceCodeComponent({
4695
4672
  lineNumber: true,
4696
4673
  autoBreak: true,
4697
4674
  lang: 'latex',
@@ -4720,15 +4697,15 @@ class KatexEditor extends Textbus {
4720
4697
 
4721
4698
  class KatexComponent extends Component {
4722
4699
  static fromJSON(textbus, state) {
4723
- return new KatexComponent(textbus, state);
4700
+ return new KatexComponent(state);
4724
4701
  }
4725
- constructor(textbus, state = {
4702
+ constructor(state = {
4726
4703
  text: '% \\f is defined as #1f(#2) using the macro\n' +
4727
4704
  '\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
4728
4705
  '\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
4729
4706
  '\\,d\\xi'
4730
4707
  }) {
4731
- super(textbus, state);
4708
+ super(state);
4732
4709
  }
4733
4710
  getSlots() {
4734
4711
  return [];
@@ -4816,9 +4793,9 @@ const katexComponentLoader = {
4816
4793
  match(element) {
4817
4794
  return element.dataset.component === KatexComponent.componentName;
4818
4795
  },
4819
- read(element, textbus) {
4796
+ read(element) {
4820
4797
  const value = element.dataset.katex || '';
4821
- return new KatexComponent(textbus, {
4798
+ return new KatexComponent({
4822
4799
  text: decodeURIComponent(value)
4823
4800
  });
4824
4801
  }
@@ -4862,7 +4839,7 @@ function InsertMenu(props) {
4862
4839
  if (/h[1-6]/.test(type)) {
4863
4840
  slot.setAttribute(headingAttr, type);
4864
4841
  }
4865
- const p = new ParagraphComponent(textbus, {
4842
+ const p = new ParagraphComponent({
4866
4843
  slot
4867
4844
  });
4868
4845
  insertComponent(p);
@@ -4876,7 +4853,7 @@ function InsertMenu(props) {
4876
4853
  ContentType.InlineComponent,
4877
4854
  ContentType.Text
4878
4855
  ]);
4879
- const list = new ListComponent(textbus, {
4856
+ const list = new ListComponent({
4880
4857
  slot,
4881
4858
  reorder: true,
4882
4859
  type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
@@ -4890,7 +4867,7 @@ function InsertMenu(props) {
4890
4867
  const slot = new Slot([
4891
4868
  ContentType.Text
4892
4869
  ]);
4893
- const comp = new SourceCodeComponent(textbus, {
4870
+ const comp = new SourceCodeComponent({
4894
4871
  lang: '',
4895
4872
  lineNumber: true,
4896
4873
  slots: [{
@@ -4904,7 +4881,7 @@ function InsertMenu(props) {
4904
4881
  break;
4905
4882
  case 'table':
4906
4883
  {
4907
- const table = new TableComponent(textbus);
4884
+ const table = new TableComponent();
4908
4885
  insertComponent(table);
4909
4886
  textbus.nextTick(() => {
4910
4887
  selection.selectFirstPosition(table, true, true);
@@ -4917,7 +4894,7 @@ function InsertMenu(props) {
4917
4894
  ContentType.Text,
4918
4895
  ContentType.InlineComponent
4919
4896
  ]);
4920
- const comp = new TodolistComponent(textbus, {
4897
+ const comp = new TodolistComponent({
4921
4898
  slot,
4922
4899
  checked: false
4923
4900
  });
@@ -4928,7 +4905,7 @@ function InsertMenu(props) {
4928
4905
  case 'image':
4929
4906
  if (fileUploader) {
4930
4907
  Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
4931
- const img = new ImageComponent(textbus, {
4908
+ const img = new ImageComponent({
4932
4909
  src: url
4933
4910
  });
4934
4911
  commander.insert(img);
@@ -4938,7 +4915,7 @@ function InsertMenu(props) {
4938
4915
  case 'video':
4939
4916
  if (fileUploader) {
4940
4917
  Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
4941
- const img = new VideoComponent(textbus, {
4918
+ const img = new VideoComponent({
4942
4919
  src: url
4943
4920
  });
4944
4921
  commander.insert(img);
@@ -4947,8 +4924,8 @@ function InsertMenu(props) {
4947
4924
  break;
4948
4925
  case 'highlightBox':
4949
4926
  {
4950
- const p = new ParagraphComponent(textbus);
4951
- const comp = new HighlightBoxComponent(textbus);
4927
+ const p = new ParagraphComponent();
4928
+ const comp = new HighlightBoxComponent();
4952
4929
  comp.state.slot.insert(p);
4953
4930
  insertComponent(comp);
4954
4931
  selection.setPosition(p.state.slot, 0);
@@ -4956,8 +4933,8 @@ function InsertMenu(props) {
4956
4933
  break;
4957
4934
  case 'katex':
4958
4935
  {
4959
- const p = new ParagraphComponent(textbus);
4960
- const comp = new KatexComponent(textbus);
4936
+ const p = new ParagraphComponent();
4937
+ const comp = new KatexComponent();
4961
4938
  p.state.slot.insert(comp);
4962
4939
  insertComponent(p);
4963
4940
  selection.selectComponent(comp);
@@ -4965,17 +4942,17 @@ function InsertMenu(props) {
4965
4942
  break;
4966
4943
  case 'step':
4967
4944
  {
4968
- const step = new StepComponent(textbus, {
4945
+ const step = new StepComponent({
4969
4946
  step: 0,
4970
- items: [createStepItem(textbus)]
4947
+ items: [createStepItem()]
4971
4948
  });
4972
4949
  insertComponent(step);
4973
4950
  selection.selectFirstPosition(step, false, true);
4974
4951
  }
4975
4952
  break;
4976
4953
  case 'timeline': {
4977
- const timeline = new TimelineComponent(textbus, {
4978
- items: [createTimelineItem(textbus, '#296eff')]
4954
+ const timeline = new TimelineComponent({
4955
+ items: [createTimelineItem('#296eff')]
4979
4956
  });
4980
4957
  insertComponent(timeline);
4981
4958
  selection.selectFirstPosition(timeline, false, true);
@@ -5008,7 +4985,7 @@ function ItalicTool() {
5008
4985
  const query = inject(Query);
5009
4986
  const refreshService = inject(RefreshService);
5010
4987
  const textbus = inject(Textbus);
5011
- const [viewModel, update] = useProduce({
4988
+ const viewModel = reactive({
5012
4989
  highlight: false,
5013
4990
  });
5014
4991
  function toggle() {
@@ -5016,17 +4993,14 @@ function ItalicTool() {
5016
4993
  }
5017
4994
  const sub = refreshService.onRefresh.subscribe(() => {
5018
4995
  const state = query.queryFormat(italicFormatter);
5019
- update(draft => {
5020
- draft.highlight = state.state === QueryStateType.Enabled;
5021
- });
4996
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5022
4997
  });
5023
4998
  onUnmounted(() => {
5024
4999
  sub.unsubscribe();
5025
5000
  });
5026
5001
  const commonState = useCommonState();
5027
5002
  return () => {
5028
- const vm = viewModel();
5029
- return jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-italic" }) });
5003
+ return jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-italic" }) });
5030
5004
  };
5031
5005
  }
5032
5006
 
@@ -5135,7 +5109,7 @@ function StrikeThroughTool() {
5135
5109
  const query = inject(Query);
5136
5110
  const refreshService = inject(RefreshService);
5137
5111
  const textbus = inject(Textbus);
5138
- const [viewModel, update] = useProduce({
5112
+ const viewModel = reactive({
5139
5113
  highlight: false,
5140
5114
  });
5141
5115
  function toggle() {
@@ -5143,17 +5117,14 @@ function StrikeThroughTool() {
5143
5117
  }
5144
5118
  const sub = refreshService.onRefresh.subscribe(() => {
5145
5119
  const state = query.queryFormat(strikeThroughFormatter);
5146
- update(draft => {
5147
- draft.highlight = state.state === QueryStateType.Enabled;
5148
- });
5120
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5149
5121
  });
5150
5122
  onUnmounted(() => {
5151
5123
  sub.unsubscribe();
5152
5124
  });
5153
5125
  const commonState = useCommonState();
5154
5126
  return () => {
5155
- const vm = viewModel();
5156
- return jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-strikethrough" }) });
5127
+ return jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-strikethrough" }) });
5157
5128
  };
5158
5129
  }
5159
5130
 
@@ -5161,13 +5132,11 @@ function SubscriptTool() {
5161
5132
  const query = inject(Query);
5162
5133
  const selection = inject(Selection);
5163
5134
  const commander = inject(Commander);
5164
- const [state, updateState] = useProduce({
5135
+ const state = reactive({
5165
5136
  highlight: false
5166
5137
  });
5167
5138
  const sub = selection.onChange.subscribe(() => {
5168
- updateState(draft => {
5169
- draft.highlight = getState();
5170
- });
5139
+ state.highlight = getState();
5171
5140
  });
5172
5141
  function getState() {
5173
5142
  const s = query.queryFormat(subscriptFormatter);
@@ -5188,7 +5157,7 @@ function SubscriptTool() {
5188
5157
  }
5189
5158
  const commonState = useCommonState();
5190
5159
  return () => {
5191
- return (jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state().highlight, onClick: apply, children: jsx("span", { class: "xnote-icon-subscript" }) }));
5160
+ return (jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsx("span", { class: "xnote-icon-subscript" }) }));
5192
5161
  };
5193
5162
  }
5194
5163
 
@@ -5196,13 +5165,11 @@ function SuperscriptTool() {
5196
5165
  const query = inject(Query);
5197
5166
  const selection = inject(Selection);
5198
5167
  const commander = inject(Commander);
5199
- const [state, updateState] = useProduce({
5168
+ const state = reactive({
5200
5169
  highlight: false
5201
5170
  });
5202
5171
  const sub = selection.onChange.subscribe(() => {
5203
- updateState(draft => {
5204
- draft.highlight = getState();
5205
- });
5172
+ state.highlight = getState();
5206
5173
  });
5207
5174
  function getState() {
5208
5175
  const s = query.queryFormat(superscriptFormatter);
@@ -5223,7 +5190,7 @@ function SuperscriptTool() {
5223
5190
  }
5224
5191
  const commonState = useCommonState();
5225
5192
  return () => {
5226
- return (jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state().highlight, onClick: apply, children: jsx("span", { class: "xnote-icon-superscript" }) }));
5193
+ return (jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsx("span", { class: "xnote-icon-superscript" }) }));
5227
5194
  };
5228
5195
  }
5229
5196
 
@@ -5325,7 +5292,7 @@ function UnderlineTool() {
5325
5292
  const query = inject(Query);
5326
5293
  const refreshService = inject(RefreshService);
5327
5294
  const textbus = inject(Textbus);
5328
- const [viewModel, update] = useProduce({
5295
+ const viewModel = reactive({
5329
5296
  highlight: false,
5330
5297
  });
5331
5298
  function toggle() {
@@ -5333,17 +5300,14 @@ function UnderlineTool() {
5333
5300
  }
5334
5301
  const sub = refreshService.onRefresh.subscribe(() => {
5335
5302
  const state = query.queryFormat(underlineFormatter);
5336
- update(draft => {
5337
- draft.highlight = state.state === QueryStateType.Enabled;
5338
- });
5303
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5339
5304
  });
5340
5305
  onUnmounted(() => {
5341
5306
  sub.unsubscribe();
5342
5307
  });
5343
5308
  const commonState = useCommonState();
5344
5309
  return () => {
5345
- const vm = viewModel();
5346
- return jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-underline" }) });
5310
+ return jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsx("span", { class: "xnote-icon-underline" }) });
5347
5311
  };
5348
5312
  }
5349
5313
 
@@ -5535,7 +5499,7 @@ const cellBackgroundAttrLoader = {
5535
5499
  function CellBackgroundTool() {
5536
5500
  const refreshService = inject(RefreshService);
5537
5501
  const selection = inject(Selection);
5538
- const [viewModel, update] = useProduce({
5502
+ const viewModel = reactive({
5539
5503
  disabled: false,
5540
5504
  });
5541
5505
  function setColor(picker) {
@@ -5576,9 +5540,7 @@ function CellBackgroundTool() {
5576
5540
  }
5577
5541
  }
5578
5542
  const sub = refreshService.onRefresh.subscribe(() => {
5579
- update(draft => {
5580
- draft.disabled = !isInTable(selection);
5581
- });
5543
+ viewModel.disabled = !isInTable(selection);
5582
5544
  });
5583
5545
  onUnmounted(() => {
5584
5546
  sub.unsubscribe();
@@ -5594,8 +5556,7 @@ function CellBackgroundTool() {
5594
5556
  '#c596e0',
5595
5557
  ];
5596
5558
  return () => {
5597
- const vm = viewModel();
5598
- const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
5559
+ const d = viewModel.disabled || commonState().readonly || commonState().inSourceCode;
5599
5560
  return (jsx(Dropdown, { width: '177px', disabled: d, menu: jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: jsx(Button, { disabled: d, arrow: true, children: jsx("span", { class: "xnote-icon-palette" }) }) }));
5600
5561
  };
5601
5562
  }
@@ -5603,7 +5564,7 @@ function CellBackgroundTool() {
5603
5564
  function MergeCellsTool() {
5604
5565
  const refreshService = inject(RefreshService);
5605
5566
  const selection = inject(Selection);
5606
- const [viewModel, update] = useProduce({
5567
+ const viewModel = reactive({
5607
5568
  highlight: false,
5608
5569
  disabled: false,
5609
5570
  });
@@ -5614,33 +5575,30 @@ function MergeCellsTool() {
5614
5575
  }
5615
5576
  }
5616
5577
  const sub = refreshService.onRefresh.subscribe(() => {
5617
- update(draft => {
5618
- const is = isInTable(selection);
5619
- if (is) {
5620
- const p1 = getTableSlotBySlot(selection.startSlot);
5621
- const p2 = getTableSlotBySlot(selection.endSlot);
5622
- if (p1 && p2) {
5623
- draft.disabled = p1 === p2;
5624
- return;
5625
- }
5578
+ const is = isInTable(selection);
5579
+ if (is) {
5580
+ const p1 = getTableSlotBySlot(selection.startSlot);
5581
+ const p2 = getTableSlotBySlot(selection.endSlot);
5582
+ if (p1 && p2) {
5583
+ viewModel.disabled = p1 === p2;
5584
+ return;
5626
5585
  }
5627
- draft.disabled = true;
5628
- });
5586
+ }
5587
+ viewModel.disabled = true;
5629
5588
  });
5630
5589
  onUnmounted(() => {
5631
5590
  sub.unsubscribe();
5632
5591
  });
5633
5592
  const commonState = useCommonState();
5634
5593
  return () => {
5635
- const vm = viewModel();
5636
- return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsx("span", { class: "xnote-icon-merge-cells" }) });
5594
+ return jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsx("span", { class: "xnote-icon-merge-cells" }) });
5637
5595
  };
5638
5596
  }
5639
5597
 
5640
5598
  function SplitCellsTool() {
5641
5599
  const refreshService = inject(RefreshService);
5642
5600
  const selection = inject(Selection);
5643
- const [viewModel, update] = useProduce({
5601
+ const viewModel = reactive({
5644
5602
  highlight: false,
5645
5603
  disabled: false,
5646
5604
  });
@@ -5665,47 +5623,44 @@ function SplitCellsTool() {
5665
5623
  }
5666
5624
  const sub = refreshService.onRefresh.subscribe(() => {
5667
5625
  const commonAncestorComponent = selection.commonAncestorComponent;
5668
- update(draft => {
5669
- if (commonAncestorComponent instanceof TableComponent) {
5670
- const slots = commonAncestorComponent.getSelectedNormalizedSlots();
5671
- if (slots) {
5672
- for (const item of slots) {
5673
- for (const cell of item.cells) {
5674
- if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
5675
- draft.disabled = false;
5676
- return;
5677
- }
5626
+ if (commonAncestorComponent instanceof TableComponent) {
5627
+ const slots = commonAncestorComponent.getSelectedNormalizedSlots();
5628
+ if (slots) {
5629
+ for (const item of slots) {
5630
+ for (const cell of item.cells) {
5631
+ if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
5632
+ viewModel.disabled = false;
5633
+ return;
5678
5634
  }
5679
5635
  }
5680
5636
  }
5681
5637
  }
5682
- else {
5683
- let parentSlot = selection.commonAncestorSlot;
5684
- while (parentSlot) {
5685
- if (parentSlot.parent instanceof TableComponent) {
5686
- const slots = parentSlot.parent.getNormalizedData();
5687
- for (const item of slots) {
5688
- for (const cell of item.cells) {
5689
- if (cell.raw.slot === parentSlot) {
5690
- draft.disabled = !(cell.colspan > 1 || cell.colspan > 1);
5691
- return;
5692
- }
5638
+ }
5639
+ else {
5640
+ let parentSlot = selection.commonAncestorSlot;
5641
+ while (parentSlot) {
5642
+ if (parentSlot.parent instanceof TableComponent) {
5643
+ const slots = parentSlot.parent.getNormalizedData();
5644
+ for (const item of slots) {
5645
+ for (const cell of item.cells) {
5646
+ if (cell.raw.slot === parentSlot) {
5647
+ viewModel.disabled = !(cell.colspan > 1 || cell.colspan > 1);
5648
+ return;
5693
5649
  }
5694
5650
  }
5695
5651
  }
5696
- parentSlot = parentSlot.parentSlot;
5697
5652
  }
5653
+ parentSlot = parentSlot.parentSlot;
5698
5654
  }
5699
- draft.disabled = true;
5700
- });
5655
+ }
5656
+ viewModel.disabled = true;
5701
5657
  });
5702
5658
  onUnmounted(() => {
5703
5659
  sub.unsubscribe();
5704
5660
  });
5705
5661
  const commonState = useCommonState();
5706
5662
  return () => {
5707
- const vm = viewModel();
5708
- return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsx("span", { class: "xnote-icon-split-cells" }) });
5663
+ return jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsx("span", { class: "xnote-icon-split-cells" }) });
5709
5664
  };
5710
5665
  }
5711
5666
 
@@ -5741,15 +5696,13 @@ const LeftToolbar = withAnnotation({
5741
5696
  refreshService.onRefresh.next();
5742
5697
  }
5743
5698
  }
5744
- const [positionSignal, updatePosition] = useProduce({
5699
+ const positionSignal = reactive({
5745
5700
  left: 0,
5746
5701
  top: 0,
5747
5702
  display: false
5748
5703
  });
5749
5704
  const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
5750
- updatePosition(d => {
5751
- d.display = editorService.canShowLeftToolbar;
5752
- });
5705
+ positionSignal.display = editorService.canShowLeftToolbar;
5753
5706
  });
5754
5707
  onUnmounted(() => {
5755
5708
  sub.unsubscribe();
@@ -5787,18 +5740,14 @@ const LeftToolbar = withAnnotation({
5787
5740
  slot.parent instanceof SourceCodeComponent ||
5788
5741
  slot.parent instanceof TableComponent);
5789
5742
  const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
5790
- updatePosition(draft => {
5791
- const containerRect = docContentContainer.getBoundingClientRect();
5792
- const currentRect = nativeNode.getBoundingClientRect();
5793
- draft.display = true;
5794
- draft.left = currentRect.left - containerRect.left;
5795
- draft.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
5796
- });
5743
+ const containerRect = docContentContainer.getBoundingClientRect();
5744
+ const currentRect = nativeNode.getBoundingClientRect();
5745
+ positionSignal.display = true;
5746
+ positionSignal.left = currentRect.left - containerRect.left;
5747
+ positionSignal.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
5797
5748
  }
5798
5749
  else {
5799
- updatePosition(draft => {
5800
- draft.display = false;
5801
- });
5750
+ positionSignal.display = false;
5802
5751
  isEmptyBlock.set(false);
5803
5752
  }
5804
5753
  });
@@ -5877,7 +5826,6 @@ const LeftToolbar = withAnnotation({
5877
5826
  }
5878
5827
  return withScopedCSS(scopedId$a, () => {
5879
5828
  var _a;
5880
- const position = positionSignal();
5881
5829
  const slot = activeSlot();
5882
5830
  let activeNode = jsx("span", { class: "xnote-icon-pilcrow" });
5883
5831
  const states = checkStates(slot);
@@ -5907,9 +5855,9 @@ const LeftToolbar = withAnnotation({
5907
5855
  const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
5908
5856
  const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
5909
5857
  return (jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
5910
- left: position.left + 'px',
5911
- top: position.top + 'px',
5912
- display: position.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5858
+ left: positionSignal.left + 'px',
5859
+ top: positionSignal.top + 'px',
5860
+ display: positionSignal.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5913
5861
  }, children: jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
5914
5862
  position: 'absolute',
5915
5863
  right: 0,
@@ -6037,14 +5985,14 @@ const InlineToolbar = withAnnotation({
6037
5985
  const subscription = merge(textbus.onChange, selection.onChange).pipe(debounceTime(20), tap(() => {
6038
5986
  refreshService.onRefresh.next();
6039
5987
  }), delay(200)).subscribe(() => {
6040
- if (viewPosition().isHide) {
5988
+ if (viewPosition.isHide) {
6041
5989
  editorService.changeLeftToolbarVisible(true);
6042
5990
  }
6043
5991
  });
6044
5992
  onUnmounted(() => {
6045
5993
  subscription.unsubscribe();
6046
5994
  });
6047
- const [viewPosition, updateViewPosition] = useProduce({
5995
+ const viewPosition = reactive({
6048
5996
  left: 0,
6049
5997
  top: 0,
6050
5998
  isHide: true,
@@ -6122,21 +6070,17 @@ const InlineToolbar = withAnnotation({
6122
6070
  const top = toBottom ?
6123
6071
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
6124
6072
  selectionFocusRect.top - docRect.top - toolbarHeight - 10;
6125
- updateViewPosition(draft => {
6126
- draft.transitionDuration = .15;
6127
- draft.left = centerLeft - docRect.left;
6128
- // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
6129
- draft.top = top + 10;
6130
- });
6073
+ viewPosition.transitionDuration = .15;
6074
+ viewPosition.left = centerLeft - docRect.left;
6075
+ // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
6076
+ viewPosition.top = top + 10;
6131
6077
  return top;
6132
6078
  }
6133
6079
  const sub = textbus.onChange.pipe(debounceTime(100)).subscribe(() => {
6134
- if (!viewPosition().isHide) {
6080
+ if (!viewPosition.isHide) {
6135
6081
  const top = getTop();
6136
6082
  if (top !== null && !selection.isCollapsed) {
6137
- updateViewPosition(draft => {
6138
- draft.top = top;
6139
- });
6083
+ viewPosition.top = top;
6140
6084
  return;
6141
6085
  }
6142
6086
  }
@@ -6159,11 +6103,9 @@ const InlineToolbar = withAnnotation({
6159
6103
  return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
6160
6104
  }), map(getTop), delay(200)).subscribe((top) => {
6161
6105
  if (top !== null) {
6162
- updateViewPosition(draft => {
6163
- draft.isHide = false;
6164
- draft.opacity = 1;
6165
- draft.top = top;
6166
- });
6106
+ viewPosition.isHide = false;
6107
+ viewPosition.opacity = 1;
6108
+ viewPosition.top = top;
6167
6109
  editorService.changeLeftToolbarVisible(false);
6168
6110
  }
6169
6111
  else {
@@ -6176,11 +6118,9 @@ const InlineToolbar = withAnnotation({
6176
6118
  return;
6177
6119
  }
6178
6120
  mouseupSubscription.unsubscribe();
6179
- updateViewPosition(draft => {
6180
- draft.opacity = 0;
6181
- draft.isHide = true;
6182
- draft.transitionDuration = 0;
6183
- });
6121
+ viewPosition.opacity = 0;
6122
+ viewPosition.isHide = true;
6123
+ viewPosition.transitionDuration = 0;
6184
6124
  bindMouseup();
6185
6125
  });
6186
6126
  const instance = getCurrentInstance();
@@ -6193,14 +6133,13 @@ const InlineToolbar = withAnnotation({
6193
6133
  mouseupSubscription.unsubscribe();
6194
6134
  });
6195
6135
  return withScopedCSS(scopedId$8, () => {
6196
- const p = viewPosition();
6197
6136
  return (jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
6198
- left: p.left + 'px',
6199
- top: p.top + 'px',
6200
- pointerEvents: p.isHide ? 'none' : 'initial',
6201
- opacity: p.opacity,
6137
+ left: viewPosition.left + 'px',
6138
+ top: viewPosition.top + 'px',
6139
+ pointerEvents: viewPosition.isHide ? 'none' : 'initial',
6140
+ opacity: viewPosition.opacity,
6202
6141
  display: editorService.hideInlineToolbar ? 'none' : '',
6203
- transitionDuration: p.transitionDuration + 's'
6142
+ transitionDuration: viewPosition.transitionDuration + 's'
6204
6143
  }, children: [jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(TextColorTool, {}) }), jsx(ToolbarItem, { children: jsx(TextBackgroundColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
6205
6144
  });
6206
6145
  });
@@ -6288,10 +6227,11 @@ class StaticToolbarPlugin {
6288
6227
  const container = document.createElement('div');
6289
6228
  container.style.position = 'relative';
6290
6229
  container.style.borderRadius = 'inherit';
6291
- this.app = createApp(jsx(Context, { providers: [{
6292
- provide: DropdownMenuContainer,
6293
- useValue: container
6294
- }], children: jsx(StaticToolbar, { theme: this.options.theme }) }), {
6230
+ const Context = createContext([{
6231
+ provide: DropdownMenuContainer,
6232
+ useValue: container
6233
+ }]);
6234
+ this.app = createApp(jsx(Context, { children: jsx(StaticToolbar, { theme: this.options.theme }) }), {
6295
6235
  context: injector
6296
6236
  });
6297
6237
  this.options.host.appendChild(container);
@@ -6323,39 +6263,30 @@ const SuspensionToolbar = withAnnotation({
6323
6263
  onUnmounted(() => {
6324
6264
  subscription.unsubscribe();
6325
6265
  });
6326
- const [styles, updateStyles] = useProduce({
6266
+ const styles = reactive({
6327
6267
  top: 0,
6328
6268
  opacity: 1,
6329
6269
  });
6330
6270
  subscription.add(fromEvent(document, 'scroll').pipe(tap(() => {
6331
- updateStyles(draft => {
6332
- draft.opacity = 0;
6333
- });
6271
+ styles.opacity = 0;
6334
6272
  }), debounceTime(100), tap(() => {
6335
6273
  const rect = viewDocument.getBoundingClientRect();
6336
6274
  if (rect.top < 10) {
6337
- updateStyles(draft => {
6338
- draft.top = Math.min(-rect.top + 10, rect.height - 100);
6339
- });
6275
+ styles.top = Math.min(-rect.top + 10, rect.height - 100);
6340
6276
  }
6341
6277
  else {
6342
- updateStyles(draft => {
6343
- draft.top = 0;
6344
- });
6278
+ styles.top = 0;
6345
6279
  }
6346
6280
  }), delay(100)).subscribe(() => {
6347
- updateStyles(draft => {
6348
- draft.opacity = 1;
6349
- });
6281
+ styles.opacity = 1;
6350
6282
  }));
6351
6283
  return withScopedCSS(scopedId$6, () => {
6352
- const s = styles();
6353
6284
  return (jsxs("div", { class: ['toolbar', props.theme, {
6354
- suspension: s.top === 0 ? '' : 'suspension'
6285
+ suspension: styles.top === 0 ? '' : 'suspension'
6355
6286
  }], style: {
6356
- top: s.top + 'px',
6357
- opacity: s.opacity,
6358
- pointerEvents: s.opacity === 0 ? 'none' : 'initial',
6287
+ top: styles.top + 'px',
6288
+ opacity: styles.opacity,
6289
+ pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
6359
6290
  }, children: [jsx(ToolbarItem, { children: jsx(UndoTool, {}) }), jsx(ToolbarItem, { children: jsx(RedoTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(InsertTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, {}) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(TextColorTool, {}) }), jsx(ToolbarItem, { children: jsx(TextBackgroundColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
6360
6291
  });
6361
6292
  });
@@ -6538,7 +6469,7 @@ function registerAtShortcut(textbus) {
6538
6469
  if (commonAncestorComponent instanceof SourceCodeComponent) {
6539
6470
  return false;
6540
6471
  }
6541
- const at = new AtComponent(textbus);
6472
+ const at = new AtComponent();
6542
6473
  commander.insert(at);
6543
6474
  selection.setPosition(at.state.slot, 0);
6544
6475
  }
@@ -6549,21 +6480,21 @@ class AtComponent extends Component {
6549
6480
  const registry = textbus.get(Registry);
6550
6481
  if (slotState) {
6551
6482
  const slot = registry.createSlot(slotState);
6552
- return new AtComponent(textbus, {
6483
+ return new AtComponent({
6553
6484
  slot
6554
6485
  });
6555
6486
  }
6556
- return new AtComponent(textbus, {
6487
+ return new AtComponent({
6557
6488
  userInfo,
6558
6489
  });
6559
6490
  }
6560
- constructor(textbus, state = {
6491
+ constructor(state = {
6561
6492
  slot: new Slot([ContentType.Text])
6562
6493
  }) {
6563
6494
  if (!state.userInfo && !state.slot) {
6564
6495
  state.slot = new Slot([ContentType.Text]);
6565
6496
  }
6566
- super(textbus, state);
6497
+ super(state);
6567
6498
  Object.defineProperty(this, "focus", {
6568
6499
  enumerable: true,
6569
6500
  configurable: true,
@@ -6586,13 +6517,13 @@ class AtComponent extends Component {
6586
6517
  enumerable: true,
6587
6518
  configurable: true,
6588
6519
  writable: true,
6589
- value: this.textbus.get(Selection)
6520
+ value: void 0
6590
6521
  });
6591
6522
  Object.defineProperty(this, "organization", {
6592
6523
  enumerable: true,
6593
6524
  configurable: true,
6594
6525
  writable: true,
6595
- value: this.textbus.get(Organization)
6526
+ value: void 0
6596
6527
  });
6597
6528
  }
6598
6529
  getSlots() {
@@ -6605,6 +6536,8 @@ class AtComponent extends Component {
6605
6536
  return [];
6606
6537
  }
6607
6538
  setup() {
6539
+ this.selection = useContext(Selection);
6540
+ this.organization = useContext(Organization);
6608
6541
  let isFocus = false;
6609
6542
  onFocus(() => {
6610
6543
  isFocus = true;
@@ -6679,7 +6612,7 @@ class AtComponent extends Component {
6679
6612
  this.focus.next(true);
6680
6613
  }
6681
6614
  });
6682
- onDestroy(() => {
6615
+ onDetach(() => {
6683
6616
  subs.unsubscribe();
6684
6617
  });
6685
6618
  }
@@ -6769,12 +6702,12 @@ const atComponentLoader = {
6769
6702
  read(element, textbus, slotParser) {
6770
6703
  const data = element.dataset.info;
6771
6704
  if (data) {
6772
- return new AtComponent(textbus, {
6705
+ return new AtComponent({
6773
6706
  userInfo: JSON.parse(decodeURIComponent(data))
6774
6707
  });
6775
6708
  }
6776
6709
  const slot = slotParser(new Slot([ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
6777
- return new AtComponent(textbus, {
6710
+ return new AtComponent({
6778
6711
  slot
6779
6712
  });
6780
6713
  }
@@ -6792,7 +6725,7 @@ class RootComponent extends Component {
6792
6725
  }
6793
6726
  static fromJSON(textbus, json) {
6794
6727
  const content = textbus.get(Registry).createSlot(json.content);
6795
- return new RootComponent(textbus, {
6728
+ return new RootComponent({
6796
6729
  content
6797
6730
  });
6798
6731
  }
@@ -6821,7 +6754,7 @@ class RootComponent extends Component {
6821
6754
  }
6822
6755
  const selection = this.textbus.get(Selection);
6823
6756
  content.retain(content.length);
6824
- const newParagraph = new ParagraphComponent(this.textbus);
6757
+ const newParagraph = new ParagraphComponent();
6825
6758
  content.insert(newParagraph);
6826
6759
  selection.setPosition(newParagraph.state.slot, 0);
6827
6760
  }
@@ -6870,7 +6803,7 @@ const rootComponentLoader = {
6870
6803
  match() {
6871
6804
  return true;
6872
6805
  },
6873
- read(element, textbus, slotParser) {
6806
+ read(element, _, slotParser) {
6874
6807
  const delta = slotParser(new Slot([
6875
6808
  ContentType.BlockComponent,
6876
6809
  ContentType.InlineComponent,
@@ -6879,7 +6812,7 @@ const rootComponentLoader = {
6879
6812
  const slot = new Slot([
6880
6813
  ContentType.BlockComponent
6881
6814
  ]);
6882
- deltaToBlock(delta, textbus).forEach(i => {
6815
+ deltaToBlock(delta).forEach(i => {
6883
6816
  slot.insert(i);
6884
6817
  });
6885
6818
  return slot;
@@ -7125,7 +7058,7 @@ function Scroll(props) {
7125
7058
  const scrollRef = createRef();
7126
7059
  const input = inject(Input);
7127
7060
  const tableService = inject(TableService);
7128
- const [showShadow, updateShowShadow] = useProduce({
7061
+ const showShadow = reactive({
7129
7062
  leftEnd: false,
7130
7063
  rightEnd: false
7131
7064
  });
@@ -7135,10 +7068,8 @@ function Scroll(props) {
7135
7068
  if (props.isFocus()) {
7136
7069
  input.caret.refresh();
7137
7070
  }
7138
- updateShowShadow(draft => {
7139
- draft.leftEnd = el.scrollLeft === 0;
7140
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7141
- });
7071
+ showShadow.leftEnd = el.scrollLeft === 0;
7072
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7142
7073
  }
7143
7074
  update();
7144
7075
  const s = fromEvent(el, 'scroll').subscribe(update);
@@ -7146,15 +7077,13 @@ function Scroll(props) {
7146
7077
  });
7147
7078
  onUpdated(() => {
7148
7079
  const el = scrollRef.current;
7149
- updateShowShadow(draft => {
7150
- draft.leftEnd = el.scrollLeft === 0;
7151
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7152
- });
7080
+ showShadow.leftEnd = el.scrollLeft === 0;
7081
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7153
7082
  });
7154
7083
  return withScopedCSS(scopedId$3, () => {
7155
7084
  return jsx("div", { ref: [scrollRef], class: ['scroll-container', {
7156
- 'left-end': showShadow().leftEnd,
7157
- 'right-end': showShadow().rightEnd,
7085
+ 'left-end': showShadow.leftEnd,
7086
+ 'right-end': showShadow.rightEnd,
7158
7087
  'active': props.isFocus(),
7159
7088
  // 'hide-selection': isSelectColumn()
7160
7089
  }], onScroll: ev => {
@@ -7297,34 +7226,30 @@ var scopedId$1 = "vf-d4c4a9";
7297
7226
  function ResizeRow(props) {
7298
7227
  const dragLineRef = createRef();
7299
7228
  const tableService = inject(TableService);
7300
- const [styles, updateStyles] = useProduce({
7229
+ const styles = reactive({
7301
7230
  visible: false,
7302
7231
  top: 0
7303
7232
  });
7304
7233
  onMounted(() => {
7305
7234
  const sub = tableService.onInsertRowBefore.subscribe(i => {
7306
7235
  if (i === null) {
7307
- updateStyles(draft => {
7308
- draft.visible = false;
7309
- });
7236
+ styles.visible = false;
7310
7237
  return;
7311
7238
  }
7312
- updateStyles(draft => {
7313
- draft.visible = true;
7314
- if (i === -1) {
7315
- draft.top = 0;
7316
- return;
7317
- }
7318
- const row = props.tableRef.current.rows.item(i);
7319
- draft.top = row.offsetTop + row.offsetHeight;
7320
- });
7239
+ styles.visible = true;
7240
+ if (i === -1) {
7241
+ styles.top = 0;
7242
+ return;
7243
+ }
7244
+ const row = props.tableRef.current.rows.item(i);
7245
+ styles.top = row.offsetTop + row.offsetHeight;
7321
7246
  });
7322
7247
  return () => sub.unsubscribe();
7323
7248
  });
7324
7249
  return withScopedCSS(scopedId$1, () => {
7325
7250
  return jsx("div", { ref: dragLineRef, style: {
7326
- display: styles().visible ? 'block' : 'none',
7327
- top: styles().top + 'px',
7251
+ display: styles.visible ? 'block' : 'none',
7252
+ top: styles.top + 'px',
7328
7253
  width: sum(props.component.state.columnsConfig) + 'px'
7329
7254
  }, class: 'drag-line' });
7330
7255
  });
@@ -7333,7 +7258,7 @@ function ResizeRow(props) {
7333
7258
  var scopedId = "vf-4a5ad1";
7334
7259
 
7335
7260
  function SelectionMask(props) {
7336
- const [styles, updateStyles] = useProduce({
7261
+ const styles = reactive({
7337
7262
  visible: false,
7338
7263
  left: 0,
7339
7264
  top: 0,
@@ -7347,6 +7272,7 @@ function SelectionMask(props) {
7347
7272
  });
7348
7273
  watch(props.component.tableSelection, update);
7349
7274
  function update() {
7275
+ var _a;
7350
7276
  const selection = props.component.tableSelection();
7351
7277
  const state = props.component.state;
7352
7278
  if (isShowMask(props.component)) {
@@ -7363,21 +7289,16 @@ function SelectionMask(props) {
7363
7289
  heightCompensation += 0.5;
7364
7290
  }
7365
7291
  const trs = Array.from(props.tableRef.current.rows);
7366
- updateStyles(draft => {
7367
- var _a;
7368
- const height = trs[selection.endRow - 1].offsetHeight ||
7369
- ((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
7370
- draft.visible = true;
7371
- draft.left = sum(state.columnsConfig.slice(0, selection.startColumn));
7372
- draft.top = trs[selection.startRow].offsetTop + topCompensation;
7373
- draft.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
7374
- draft.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - draft.top + 'px';
7375
- });
7292
+ const height = trs[selection.endRow - 1].offsetHeight ||
7293
+ ((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
7294
+ styles.visible = true;
7295
+ styles.left = sum(state.columnsConfig.slice(0, selection.startColumn));
7296
+ styles.top = trs[selection.startRow].offsetTop + topCompensation;
7297
+ styles.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
7298
+ styles.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - styles.top + 'px';
7376
7299
  }
7377
7300
  else {
7378
- updateStyles(draft => {
7379
- draft.visible = false;
7380
- });
7301
+ styles.visible = false;
7381
7302
  }
7382
7303
  }
7383
7304
  const s = props.component.changeMarker.onChange.pipe(debounceTime(30)).subscribe(() => {
@@ -7387,15 +7308,14 @@ function SelectionMask(props) {
7387
7308
  s.unsubscribe();
7388
7309
  });
7389
7310
  return withScopedCSS(scopedId, () => {
7390
- const style = styles();
7391
7311
  return (jsx("div", { class: "mask", style: {
7392
- display: style.visible ? 'block' : 'none',
7393
- left: style.left + 'px',
7394
- top: style.top + 'px',
7395
- right: style.right + 'px',
7396
- width: style.width,
7397
- height: style.height,
7398
- bottom: style.bottom + 'px'
7312
+ display: styles.visible ? 'block' : 'none',
7313
+ left: styles.left + 'px',
7314
+ top: styles.top + 'px',
7315
+ right: styles.right + 'px',
7316
+ width: styles.width,
7317
+ height: styles.height,
7318
+ bottom: styles.bottom + 'px'
7399
7319
  } }));
7400
7320
  });
7401
7321
  }
@@ -7610,7 +7530,7 @@ const tableComponentLoader = {
7610
7530
  ContentType.InlineComponent,
7611
7531
  ContentType.Text
7612
7532
  ]), cell).toDelta();
7613
- const results = deltaToBlock(delta, textbus);
7533
+ const results = deltaToBlock(delta);
7614
7534
  delta.attributes.forEach((value, key) => {
7615
7535
  slot.setAttribute(key, value);
7616
7536
  });
@@ -7641,7 +7561,7 @@ const tableComponentLoader = {
7641
7561
  ContentType.InlineComponent,
7642
7562
  ContentType.Text
7643
7563
  ]), cell).toDelta();
7644
- const results = deltaToBlock(delta, textbus);
7564
+ const results = deltaToBlock(delta);
7645
7565
  delta.attributes.forEach((value, key) => {
7646
7566
  slot.setAttribute(key, value);
7647
7567
  });
@@ -7668,7 +7588,7 @@ const tableComponentLoader = {
7668
7588
  layoutWidth[i] = layoutWidth[i] || 100;
7669
7589
  }
7670
7590
  layoutWidth.length = length;
7671
- return new TableComponent(textbus, {
7591
+ return new TableComponent({
7672
7592
  columnsConfig: layoutWidth,
7673
7593
  mergeConfig: cells.mergedConfig,
7674
7594
  rows: cells.table.map(i => {
@@ -7757,7 +7677,6 @@ TableSelectionAwarenessDelegate = __decorate([
7757
7677
 
7758
7678
  function TimelineComponentView(props) {
7759
7679
  const adapter = inject(DomAdapter);
7760
- const textbus = inject(Textbus);
7761
7680
  const isOutput = useOutput();
7762
7681
  const isReadonly = useReadonly();
7763
7682
  return () => {
@@ -7770,7 +7689,7 @@ function TimelineComponentView(props) {
7770
7689
  backgroundColor: item.theme,
7771
7690
  } }), !isOutput() && !isReadonly() && jsxs("div", { class: "xnote-timeline-tools", children: [jsx(Button, { class: "xnote-timeline-add xnote-icon-plus", onClick: () => {
7772
7691
  const index = component.state.items.indexOf(item) + 1;
7773
- component.state.items.splice(index, 0, createTimelineItem(textbus, item.theme));
7692
+ component.state.items.splice(index, 0, createTimelineItem(item.theme));
7774
7693
  } }), jsx(Button, { class: "xnote-timeline-add xnote-icon-bin", onClick: () => {
7775
7694
  const index = component.state.items.indexOf(item);
7776
7695
  component.state.items.splice(index, 1);
@@ -7786,8 +7705,8 @@ const timelineComponentLoader = {
7786
7705
  match(element) {
7787
7706
  return element.className === 'xnote-timeline';
7788
7707
  },
7789
- read(element, context, slotParser) {
7790
- return new TimelineComponent(context, {
7708
+ read(element, _, slotParser) {
7709
+ return new TimelineComponent({
7791
7710
  items: Array.from(element.children).map(child => {
7792
7711
  const slot = new Slot([
7793
7712
  ContentType.BlockComponent
@@ -7803,7 +7722,6 @@ const timelineComponentLoader = {
7803
7722
 
7804
7723
  function StepComponentView(props) {
7805
7724
  const adapter = inject(DomAdapter);
7806
- const textbus = inject(Textbus);
7807
7725
  const isOutput = useOutput();
7808
7726
  const isReadonly = useReadonly();
7809
7727
  return () => {
@@ -7829,7 +7747,7 @@ function StepComponentView(props) {
7829
7747
  }
7830
7748
  }, children: index + 1 })] }), !isOutput() && !isReadonly() && jsxs("div", { class: "xnote-step-tools", children: [jsx(Button, { class: "xnote-step-add xnote-icon-plus", onClick: () => {
7831
7749
  const index = component.state.items.indexOf(item) + 1;
7832
- component.state.items.splice(index, 0, createStepItem(textbus));
7750
+ component.state.items.splice(index, 0, createStepItem());
7833
7751
  } }), jsx(Button, { class: "xnote-step-add xnote-icon-bin", onClick: () => {
7834
7752
  const index = component.state.items.indexOf(item);
7835
7753
  component.state.items.splice(index, 1);
@@ -7845,8 +7763,8 @@ const stepComponentLoader = {
7845
7763
  match(element) {
7846
7764
  return element.dataset.component === StepComponent.componentName;
7847
7765
  },
7848
- read(element, context, slotParser) {
7849
- return new StepComponent(context, {
7766
+ read(element, _, slotParser) {
7767
+ return new StepComponent({
7850
7768
  step: Number(element.dataset.step) || 0,
7851
7769
  items: Array.from(element.children).map(child => {
7852
7770
  const slot = new Slot([
@@ -8128,7 +8046,7 @@ class Editor extends Textbus {
8128
8046
  rootComp = this.createModel(config.content);
8129
8047
  }
8130
8048
  else {
8131
- rootComp = new RootComponent(this, {
8049
+ rootComp = new RootComponent({
8132
8050
  content: new Slot([ContentType.BlockComponent])
8133
8051
  });
8134
8052
  }
@@ -8164,11 +8082,11 @@ class Editor extends Textbus {
8164
8082
  ContentType.BlockComponent
8165
8083
  ]);
8166
8084
  if (doc instanceof Slot) {
8167
- deltaToBlock(doc.toDelta(), this).forEach(i => {
8085
+ deltaToBlock(doc.toDelta()).forEach(i => {
8168
8086
  content.insert(i);
8169
8087
  });
8170
8088
  }
8171
- return new RootComponent(this, {
8089
+ return new RootComponent({
8172
8090
  content
8173
8091
  });
8174
8092
  }