@textbus/xnote 0.3.4 → 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);
@@ -2286,7 +2287,8 @@ function SourceCodeView(props) {
2286
2287
  }
2287
2288
  }
2288
2289
  return createVNode('div', {
2289
- class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
2290
+ class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
2291
+ key: item.slot.id
2290
2292
  }, [
2291
2293
  createVNode('span', { class: 'xnote-source-code-line-content' }, children)
2292
2294
  ]);
@@ -2322,7 +2324,7 @@ const sourceCodeComponentLoader = {
2322
2324
  ((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
2323
2325
  element.tagName === 'PRE');
2324
2326
  },
2325
- read(el, textbus) {
2327
+ read(el) {
2326
2328
  let slots = [];
2327
2329
  if (el.tagName === 'DIV') {
2328
2330
  const lines = el.querySelectorAll('.xnote-source-code-line');
@@ -2345,7 +2347,7 @@ const sourceCodeComponentLoader = {
2345
2347
  return item;
2346
2348
  });
2347
2349
  }
2348
- return new SourceCodeComponent(textbus, {
2350
+ return new SourceCodeComponent({
2349
2351
  lang: el.dataset.lang || '',
2350
2352
  theme: el.dataset.theme || '',
2351
2353
  lineNumber: el.dataset.lineNumber === 'true',
@@ -2440,7 +2442,7 @@ function registerTextIndentShortcut(textbus) {
2440
2442
 
2441
2443
  class ImageComponent extends Component {
2442
2444
  static fromJSON(textbus, json) {
2443
- return new ImageComponent(textbus, Object.assign({}, json));
2445
+ return new ImageComponent(Object.assign({}, json));
2444
2446
  }
2445
2447
  getSlots() {
2446
2448
  return [];
@@ -2480,9 +2482,9 @@ const imageComponentLoader = {
2480
2482
  match(element) {
2481
2483
  return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2482
2484
  },
2483
- read(element, textbus) {
2485
+ read(element) {
2484
2486
  const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2485
- return new ImageComponent(textbus, {
2487
+ return new ImageComponent({
2486
2488
  src: img.src,
2487
2489
  width: img.style.width || 'auto',
2488
2490
  height: img.style.height || 'auto'
@@ -2491,8 +2493,8 @@ const imageComponentLoader = {
2491
2493
  };
2492
2494
 
2493
2495
  class VideoComponent extends Component {
2494
- static fromJSON(textbus, json) {
2495
- return new VideoComponent(textbus, Object.assign({}, json));
2496
+ static fromJSON(_, json) {
2497
+ return new VideoComponent(Object.assign({}, json));
2496
2498
  }
2497
2499
  getSlots() {
2498
2500
  return [];
@@ -2532,9 +2534,9 @@ const videoComponentLoader = {
2532
2534
  match(element) {
2533
2535
  return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2534
2536
  },
2535
- read(element, textbus) {
2537
+ read(element) {
2536
2538
  const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2537
- return new VideoComponent(textbus, {
2539
+ return new VideoComponent({
2538
2540
  src: video.src,
2539
2541
  width: video.style.width || 'auto',
2540
2542
  height: video.style.height || 'auto'
@@ -2544,18 +2546,6 @@ const videoComponentLoader = {
2544
2546
 
2545
2547
  let ToolService = class ToolService {
2546
2548
  constructor(selection, controller) {
2547
- Object.defineProperty(this, "selection", {
2548
- enumerable: true,
2549
- configurable: true,
2550
- writable: true,
2551
- value: selection
2552
- });
2553
- Object.defineProperty(this, "controller", {
2554
- enumerable: true,
2555
- configurable: true,
2556
- writable: true,
2557
- value: controller
2558
- });
2559
2549
  Object.defineProperty(this, "state", {
2560
2550
  enumerable: true,
2561
2551
  configurable: true,
@@ -2568,12 +2558,11 @@ let ToolService = class ToolService {
2568
2558
  writable: true,
2569
2559
  value: void 0
2570
2560
  });
2571
- const [state, updateState] = useProduce({
2561
+ this.state = createSignal({
2572
2562
  inSourceCode: false,
2573
2563
  readonly: controller.readonly,
2574
2564
  selectEmbed: false,
2575
2565
  });
2576
- this.state = state;
2577
2566
  this.sub = merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2578
2567
  const { startSlot, endSlot, startOffset, endOffset } = selection;
2579
2568
  let is = false;
@@ -2583,10 +2572,10 @@ let ToolService = class ToolService {
2583
2572
  is = true;
2584
2573
  }
2585
2574
  }
2586
- updateState(draft => {
2587
- draft.selectEmbed = is;
2588
- draft.readonly = controller.readonly;
2589
- draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
2575
+ this.state.set({
2576
+ selectEmbed: is,
2577
+ readonly: controller.readonly,
2578
+ inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
2590
2579
  });
2591
2580
  });
2592
2581
  }
@@ -2610,7 +2599,7 @@ function AttrTool(props) {
2610
2599
  const selection = inject(Selection);
2611
2600
  const query = inject(Query);
2612
2601
  const refreshService = inject(RefreshService);
2613
- const [checkStates, setCheckStates] = useProduce({
2602
+ const checkStates = reactive({
2614
2603
  textAlign: 'left',
2615
2604
  textIndent: 0
2616
2605
  });
@@ -2618,23 +2607,21 @@ function AttrTool(props) {
2618
2607
  if (!props.slot && !selection.isSelected) {
2619
2608
  return;
2620
2609
  }
2621
- setCheckStates(draft => {
2622
- const range = props.slot ? {
2623
- startSlot: props.slot,
2624
- endSlot: props.slot,
2625
- startOffset: 0,
2626
- endOffset: props.slot.length
2627
- } : {
2628
- startSlot: selection.startSlot,
2629
- startOffset: selection.startOffset,
2630
- endSlot: selection.endSlot,
2631
- endOffset: selection.endOffset
2632
- };
2633
- const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
2634
- const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
2635
- draft.textAlign = textAlignState.state === QueryStateType.Enabled ? textAlignState.value : 'left';
2636
- draft.textIndent = textIndentState.state === QueryStateType.Enabled ? textIndentState.value : 0;
2637
- });
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;
2638
2625
  }
2639
2626
  updateCheckStates();
2640
2627
  const subscription = refreshService.onRefresh.subscribe(() => {
@@ -2683,20 +2670,19 @@ function AttrTool(props) {
2683
2670
  }
2684
2671
  const commonState = useCommonState();
2685
2672
  return withScopedCSS(scopedId$e, () => {
2686
- const states = checkStates();
2687
2673
  const b = commonState().inSourceCode || commonState().readonly;
2688
2674
  return (jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
2689
2675
  {
2690
- 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" }),
2691
2677
  value: 't-l'
2692
2678
  }, {
2693
- 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" }),
2694
2680
  value: 't-r'
2695
2681
  }, {
2696
- 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" }),
2697
2683
  value: 't-c'
2698
2684
  }, {
2699
- 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" }),
2700
2686
  value: 't-j'
2701
2687
  }, {
2702
2688
  label: jsx(Divider, {}),
@@ -2708,7 +2694,7 @@ function AttrTool(props) {
2708
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" }),
2709
2695
  value: 'i-'
2710
2696
  }
2711
- ], 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` }) }) }));
2712
2698
  });
2713
2699
  }
2714
2700
 
@@ -2823,7 +2809,7 @@ const defaultColumnWidth = 100;
2823
2809
  class TableComponent extends Component {
2824
2810
  static fromJSON(textbus, json) {
2825
2811
  const registry = textbus.get(Registry);
2826
- return new TableComponent(textbus, {
2812
+ return new TableComponent({
2827
2813
  columnsConfig: json.columnsConfig || [],
2828
2814
  mergeConfig: json.mergeConfig || [],
2829
2815
  rows: json.rows.map(row => {
@@ -2839,14 +2825,14 @@ class TableComponent extends Component {
2839
2825
  })
2840
2826
  });
2841
2827
  }
2842
- constructor(textbus, state = {
2828
+ constructor(state = {
2843
2829
  columnsConfig: Array.from({ length: 5 }).fill(defaultColumnWidth),
2844
2830
  mergeConfig: {},
2845
2831
  rows: Array.from({ length: 3 }).map(() => {
2846
2832
  return {
2847
2833
  height: defaultRowHeight,
2848
2834
  cells: Array.from({ length: 5 }).map(() => {
2849
- const p = new ParagraphComponent(textbus);
2835
+ const p = new ParagraphComponent();
2850
2836
  const slot = new Slot([ContentType.BlockComponent]);
2851
2837
  slot.insert(p);
2852
2838
  return {
@@ -2857,18 +2843,18 @@ class TableComponent extends Component {
2857
2843
  };
2858
2844
  })
2859
2845
  }) {
2860
- super(textbus, state);
2846
+ super(state);
2861
2847
  Object.defineProperty(this, "selection", {
2862
2848
  enumerable: true,
2863
2849
  configurable: true,
2864
2850
  writable: true,
2865
- value: this.textbus.get(Selection)
2851
+ value: void 0
2866
2852
  });
2867
2853
  Object.defineProperty(this, "commander", {
2868
2854
  enumerable: true,
2869
2855
  configurable: true,
2870
2856
  writable: true,
2871
- value: this.textbus.get(Commander)
2857
+ value: void 0
2872
2858
  });
2873
2859
  Object.defineProperty(this, "focus", {
2874
2860
  enumerable: true,
@@ -3133,6 +3119,8 @@ class TableComponent extends Component {
3133
3119
  }
3134
3120
  setup() {
3135
3121
  const selection = useContext(Selection);
3122
+ this.selection = selection;
3123
+ this.commander = useContext(Commander);
3136
3124
  onFocusIn(() => {
3137
3125
  this.focus.next(true);
3138
3126
  });
@@ -3150,7 +3138,7 @@ class TableComponent extends Component {
3150
3138
  this.tableSelection.set(null);
3151
3139
  }
3152
3140
  });
3153
- onDestroy(() => {
3141
+ onDetach(() => {
3154
3142
  sub.unsubscribe();
3155
3143
  });
3156
3144
  onGetRanges(ev => {
@@ -3260,7 +3248,7 @@ class TableComponent extends Component {
3260
3248
  const slot = new Slot([
3261
3249
  ContentType.BlockComponent,
3262
3250
  ]);
3263
- slot.insert(new ParagraphComponent(this.textbus, {
3251
+ slot.insert(new ParagraphComponent({
3264
3252
  slot: new Slot([
3265
3253
  ContentType.InlineComponent,
3266
3254
  ContentType.Text
@@ -3285,7 +3273,7 @@ class TableComponent extends Component {
3285
3273
  const slot = new Slot([
3286
3274
  ContentType.BlockComponent,
3287
3275
  ]);
3288
- slot.insert(new ParagraphComponent(this.textbus, {
3276
+ slot.insert(new ParagraphComponent({
3289
3277
  slot: new Slot([
3290
3278
  ContentType.InlineComponent,
3291
3279
  ContentType.Text
@@ -3366,7 +3354,7 @@ const strikeThroughFormatLoader = {
3366
3354
  class TodolistComponent extends Component {
3367
3355
  static fromJSON(textbus, json) {
3368
3356
  const slot = textbus.get(Registry).createSlot(json.slot);
3369
- return new TodolistComponent(textbus, {
3357
+ return new TodolistComponent({
3370
3358
  slot,
3371
3359
  checked: json.checked
3372
3360
  });
@@ -3375,7 +3363,6 @@ class TodolistComponent extends Component {
3375
3363
  return [this.state.slot];
3376
3364
  }
3377
3365
  setup() {
3378
- const textbus = useContext();
3379
3366
  const commander = useContext(Commander);
3380
3367
  const selection = useContext(Selection);
3381
3368
  onBreak(ev => {
@@ -3385,7 +3372,7 @@ class TodolistComponent extends Component {
3385
3372
  const beforeIndex = this.parent.indexOf(this);
3386
3373
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3387
3374
  if (beforeComponent instanceof TodolistComponent) {
3388
- const nextComponent = new ParagraphComponent(textbus, {
3375
+ const nextComponent = new ParagraphComponent({
3389
3376
  slot: new Slot([
3390
3377
  ContentType.Text,
3391
3378
  ContentType.InlineComponent
@@ -3399,7 +3386,7 @@ class TodolistComponent extends Component {
3399
3386
  return;
3400
3387
  }
3401
3388
  }
3402
- const nextParagraph = new TodolistComponent(textbus, {
3389
+ const nextParagraph = new TodolistComponent({
3403
3390
  checked: this.state.checked,
3404
3391
  slot
3405
3392
  });
@@ -3416,7 +3403,7 @@ class TodolistComponent extends Component {
3416
3403
  return false;
3417
3404
  }
3418
3405
  const slot = selection.commonAncestorSlot.cut();
3419
- const paragraph = new ParagraphComponent(textbus, {
3406
+ const paragraph = new ParagraphComponent({
3420
3407
  slot
3421
3408
  });
3422
3409
  commander.replaceComponent(this, paragraph);
@@ -3504,12 +3491,12 @@ const todolistComponentLoader = {
3504
3491
  match(element) {
3505
3492
  return element.dataset.component === TodolistComponent.componentName;
3506
3493
  },
3507
- read(element, injector, slotParser) {
3494
+ read(element, _, slotParser) {
3508
3495
  const slot = slotParser(new Slot([
3509
3496
  ContentType.Text,
3510
3497
  ContentType.InlineComponent
3511
3498
  ]), element.children[1]);
3512
- return new TodolistComponent(injector, {
3499
+ return new TodolistComponent({
3513
3500
  checked: element.children[0].hasAttribute('checked'),
3514
3501
  slot
3515
3502
  });
@@ -3528,7 +3515,7 @@ function toList(textbus, type) {
3528
3515
  },
3529
3516
  stateFactory(slots) {
3530
3517
  return slots.map((slot, index) => {
3531
- return new ListComponent(textbus, {
3518
+ return new ListComponent({
3532
3519
  type,
3533
3520
  reorder: index === 0,
3534
3521
  slot
@@ -3552,7 +3539,7 @@ function registerListShortcut(textbus) {
3552
3539
  }
3553
3540
  class ListComponent extends Component {
3554
3541
  static fromJSON(textbus, json) {
3555
- return new ListComponent(textbus, {
3542
+ return new ListComponent({
3556
3543
  type: json.type,
3557
3544
  reorder: json.reorder,
3558
3545
  slot: textbus.get(Registry).createSlot(json.slot)
@@ -3562,7 +3549,6 @@ class ListComponent extends Component {
3562
3549
  return [this.state.slot];
3563
3550
  }
3564
3551
  setup() {
3565
- const textbus = useContext();
3566
3552
  const commander = useContext(Commander);
3567
3553
  const selection = useContext(Selection);
3568
3554
  const updateAfterList = (ref) => {
@@ -3592,7 +3578,7 @@ class ListComponent extends Component {
3592
3578
  const beforeIndex = this.parent.indexOf(this);
3593
3579
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3594
3580
  if (beforeComponent instanceof ListComponent) {
3595
- const nextComponent = new ParagraphComponent(textbus, {
3581
+ const nextComponent = new ParagraphComponent({
3596
3582
  slot: new Slot([
3597
3583
  ContentType.Text,
3598
3584
  ContentType.InlineComponent
@@ -3607,7 +3593,7 @@ class ListComponent extends Component {
3607
3593
  return;
3608
3594
  }
3609
3595
  }
3610
- const nextList = new ListComponent(textbus, {
3596
+ const nextList = new ListComponent({
3611
3597
  slot,
3612
3598
  reorder: false,
3613
3599
  type: this.state.type
@@ -3626,7 +3612,7 @@ class ListComponent extends Component {
3626
3612
  return false;
3627
3613
  }
3628
3614
  const slot = selection.commonAncestorSlot.cut();
3629
- const paragraph = new ParagraphComponent(textbus, {
3615
+ const paragraph = new ParagraphComponent({
3630
3616
  slot
3631
3617
  });
3632
3618
  commander.replaceComponent(this, paragraph);
@@ -3802,7 +3788,7 @@ const listComponentLoader = {
3802
3788
  ContentType.InlineComponent,
3803
3789
  ContentType.Text
3804
3790
  ]), element.querySelector('.xnote-list-content') || document.createElement('div'));
3805
- return new ListComponent(textbus, {
3791
+ return new ListComponent({
3806
3792
  slot,
3807
3793
  reorder: element.dataset.reorder !== 'false',
3808
3794
  type
@@ -3816,7 +3802,7 @@ const listComponentLoader = {
3816
3802
  ContentType.InlineComponent,
3817
3803
  ContentType.Text
3818
3804
  ]), i);
3819
- const component = new ListComponent(textbus, {
3805
+ const component = new ListComponent({
3820
3806
  slot,
3821
3807
  reorder: index === 0,
3822
3808
  type
@@ -3831,7 +3817,7 @@ function useActiveBlock() {
3831
3817
  const query = inject(Query);
3832
3818
  const selection = inject(Selection);
3833
3819
  const refreshService = inject(RefreshService);
3834
- const [checkStates, setCheckStates] = useProduce({
3820
+ const checkStates = reactive({
3835
3821
  paragraph: false,
3836
3822
  h1: false,
3837
3823
  h2: false,
@@ -3848,22 +3834,20 @@ function useActiveBlock() {
3848
3834
  highlightBox: false
3849
3835
  });
3850
3836
  function updateCheckStates(range) {
3851
- setCheckStates(draft => {
3852
- const heading = query.queryAttributeByRange(headingAttr, range);
3853
- draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === QueryStateType.Enabled;
3854
- draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
3855
- if (heading.state === QueryStateType.Enabled) {
3856
- draft[heading.value] = true;
3857
- draft.paragraph = false;
3858
- }
3859
- const queryList = query.queryComponentByRange(ListComponent, range);
3860
- draft.unorderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
3861
- draft.orderedList = queryList.state === QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
3862
- draft.table = query.queryComponentByRange(TableComponent, range).state === QueryStateType.Enabled;
3863
- draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === QueryStateType.Enabled;
3864
- draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === QueryStateType.Enabled;
3865
- draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === QueryStateType.Enabled;
3866
- });
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;
3867
3851
  }
3868
3852
  const subscription = refreshService.onRefresh.subscribe(() => {
3869
3853
  if (!selection.isSelected) {
@@ -3896,7 +3880,7 @@ function useActiveBlock() {
3896
3880
  endOffset: selection.endOffset
3897
3881
  });
3898
3882
  }
3899
- return checkStates();
3883
+ return checkStates;
3900
3884
  };
3901
3885
  }
3902
3886
 
@@ -3927,7 +3911,7 @@ function useBlockTransform() {
3927
3911
  ]);
3928
3912
  },
3929
3913
  stateFactory(slots) {
3930
- return slots.map(slot => new ParagraphComponent(textbus, {
3914
+ return slots.map(slot => new ParagraphComponent({
3931
3915
  slot
3932
3916
  }));
3933
3917
  }
@@ -3935,7 +3919,7 @@ function useBlockTransform() {
3935
3919
  break;
3936
3920
  case 'table':
3937
3921
  {
3938
- const table = new TableComponent(textbus);
3922
+ const table = new TableComponent();
3939
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) {
3940
3924
  commander.replaceComponent(selection.commonAncestorComponent, table);
3941
3925
  }
@@ -3956,7 +3940,7 @@ function useBlockTransform() {
3956
3940
  },
3957
3941
  stateFactory(slots) {
3958
3942
  return slots.map(slot => {
3959
- return new TodolistComponent(textbus, {
3943
+ return new TodolistComponent({
3960
3944
  checked: false,
3961
3945
  slot
3962
3946
  });
@@ -3985,7 +3969,7 @@ function useBlockTransform() {
3985
3969
  },
3986
3970
  stateFactory(slots) {
3987
3971
  return slots.map(slot => {
3988
- return new ParagraphComponent(textbus, {
3972
+ return new ParagraphComponent({
3989
3973
  slot
3990
3974
  });
3991
3975
  });
@@ -4001,7 +3985,7 @@ function useBlockTransform() {
4001
3985
  ]);
4002
3986
  },
4003
3987
  stateFactory(slots) {
4004
- return [new SourceCodeComponent(textbus, {
3988
+ return [new SourceCodeComponent({
4005
3989
  lang: '',
4006
3990
  lineNumber: true,
4007
3991
  autoBreak: true,
@@ -4033,7 +4017,7 @@ function useBlockTransform() {
4033
4017
  });
4034
4018
  }
4035
4019
  else {
4036
- const block = new HighlightBoxComponent(textbus);
4020
+ const block = new HighlightBoxComponent();
4037
4021
  const slot = block.state.slot;
4038
4022
  if (selection.startSlot === selection.endSlot) {
4039
4023
  const parentComponent = selection.startSlot.parent;
@@ -4415,7 +4399,7 @@ function BoldTool() {
4415
4399
  const textbus = inject(Textbus);
4416
4400
  const refreshService = inject(RefreshService);
4417
4401
  const commonState = useCommonState();
4418
- const [viewModel, update] = useProduce({
4402
+ const viewModel = reactive({
4419
4403
  highlight: false,
4420
4404
  });
4421
4405
  function toggle() {
@@ -4423,16 +4407,13 @@ function BoldTool() {
4423
4407
  }
4424
4408
  const sub = refreshService.onRefresh.subscribe(() => {
4425
4409
  const state = query.queryFormat(boldFormatter);
4426
- update(draft => {
4427
- draft.highlight = state.state === QueryStateType.Enabled;
4428
- });
4410
+ viewModel.highlight = state.state === QueryStateType.Enabled;
4429
4411
  });
4430
4412
  onUnmounted(() => {
4431
4413
  sub.unsubscribe();
4432
4414
  });
4433
4415
  return () => {
4434
- const vm = viewModel();
4435
- 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" }) });
4436
4417
  };
4437
4418
  }
4438
4419
 
@@ -4454,7 +4435,7 @@ function CodeTool() {
4454
4435
  const refreshService = inject(RefreshService);
4455
4436
  const textbus = inject(Textbus);
4456
4437
  const commonState = useCommonState();
4457
- const [viewModel, update] = useProduce({
4438
+ const viewModel = reactive({
4458
4439
  highlight: false,
4459
4440
  });
4460
4441
  function toggle() {
@@ -4462,16 +4443,13 @@ function CodeTool() {
4462
4443
  }
4463
4444
  const sub = refreshService.onRefresh.subscribe(() => {
4464
4445
  const state = query.queryFormat(codeFormatter);
4465
- update(draft => {
4466
- draft.highlight = state.state === QueryStateType.Enabled;
4467
- });
4446
+ viewModel.highlight = state.state === QueryStateType.Enabled;
4468
4447
  });
4469
4448
  onUnmounted(() => {
4470
4449
  sub.unsubscribe();
4471
4450
  });
4472
4451
  return () => {
4473
- const vm = viewModel();
4474
- 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" }) });
4475
4453
  };
4476
4454
  }
4477
4455
 
@@ -4690,7 +4668,7 @@ class KatexEditor extends Textbus {
4690
4668
  }
4691
4669
  mount(host, code) {
4692
4670
  this.host = host;
4693
- const model = new SourceCodeComponent(this, {
4671
+ const model = new SourceCodeComponent({
4694
4672
  lineNumber: true,
4695
4673
  autoBreak: true,
4696
4674
  lang: 'latex',
@@ -4719,15 +4697,15 @@ class KatexEditor extends Textbus {
4719
4697
 
4720
4698
  class KatexComponent extends Component {
4721
4699
  static fromJSON(textbus, state) {
4722
- return new KatexComponent(textbus, state);
4700
+ return new KatexComponent(state);
4723
4701
  }
4724
- constructor(textbus, state = {
4702
+ constructor(state = {
4725
4703
  text: '% \\f is defined as #1f(#2) using the macro\n' +
4726
4704
  '\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
4727
4705
  '\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
4728
4706
  '\\,d\\xi'
4729
4707
  }) {
4730
- super(textbus, state);
4708
+ super(state);
4731
4709
  }
4732
4710
  getSlots() {
4733
4711
  return [];
@@ -4815,9 +4793,9 @@ const katexComponentLoader = {
4815
4793
  match(element) {
4816
4794
  return element.dataset.component === KatexComponent.componentName;
4817
4795
  },
4818
- read(element, textbus) {
4796
+ read(element) {
4819
4797
  const value = element.dataset.katex || '';
4820
- return new KatexComponent(textbus, {
4798
+ return new KatexComponent({
4821
4799
  text: decodeURIComponent(value)
4822
4800
  });
4823
4801
  }
@@ -4861,7 +4839,7 @@ function InsertMenu(props) {
4861
4839
  if (/h[1-6]/.test(type)) {
4862
4840
  slot.setAttribute(headingAttr, type);
4863
4841
  }
4864
- const p = new ParagraphComponent(textbus, {
4842
+ const p = new ParagraphComponent({
4865
4843
  slot
4866
4844
  });
4867
4845
  insertComponent(p);
@@ -4875,7 +4853,7 @@ function InsertMenu(props) {
4875
4853
  ContentType.InlineComponent,
4876
4854
  ContentType.Text
4877
4855
  ]);
4878
- const list = new ListComponent(textbus, {
4856
+ const list = new ListComponent({
4879
4857
  slot,
4880
4858
  reorder: true,
4881
4859
  type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
@@ -4889,7 +4867,7 @@ function InsertMenu(props) {
4889
4867
  const slot = new Slot([
4890
4868
  ContentType.Text
4891
4869
  ]);
4892
- const comp = new SourceCodeComponent(textbus, {
4870
+ const comp = new SourceCodeComponent({
4893
4871
  lang: '',
4894
4872
  lineNumber: true,
4895
4873
  slots: [{
@@ -4903,7 +4881,7 @@ function InsertMenu(props) {
4903
4881
  break;
4904
4882
  case 'table':
4905
4883
  {
4906
- const table = new TableComponent(textbus);
4884
+ const table = new TableComponent();
4907
4885
  insertComponent(table);
4908
4886
  textbus.nextTick(() => {
4909
4887
  selection.selectFirstPosition(table, true, true);
@@ -4916,7 +4894,7 @@ function InsertMenu(props) {
4916
4894
  ContentType.Text,
4917
4895
  ContentType.InlineComponent
4918
4896
  ]);
4919
- const comp = new TodolistComponent(textbus, {
4897
+ const comp = new TodolistComponent({
4920
4898
  slot,
4921
4899
  checked: false
4922
4900
  });
@@ -4927,7 +4905,7 @@ function InsertMenu(props) {
4927
4905
  case 'image':
4928
4906
  if (fileUploader) {
4929
4907
  Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
4930
- const img = new ImageComponent(textbus, {
4908
+ const img = new ImageComponent({
4931
4909
  src: url
4932
4910
  });
4933
4911
  commander.insert(img);
@@ -4937,7 +4915,7 @@ function InsertMenu(props) {
4937
4915
  case 'video':
4938
4916
  if (fileUploader) {
4939
4917
  Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
4940
- const img = new VideoComponent(textbus, {
4918
+ const img = new VideoComponent({
4941
4919
  src: url
4942
4920
  });
4943
4921
  commander.insert(img);
@@ -4946,8 +4924,8 @@ function InsertMenu(props) {
4946
4924
  break;
4947
4925
  case 'highlightBox':
4948
4926
  {
4949
- const p = new ParagraphComponent(textbus);
4950
- const comp = new HighlightBoxComponent(textbus);
4927
+ const p = new ParagraphComponent();
4928
+ const comp = new HighlightBoxComponent();
4951
4929
  comp.state.slot.insert(p);
4952
4930
  insertComponent(comp);
4953
4931
  selection.setPosition(p.state.slot, 0);
@@ -4955,8 +4933,8 @@ function InsertMenu(props) {
4955
4933
  break;
4956
4934
  case 'katex':
4957
4935
  {
4958
- const p = new ParagraphComponent(textbus);
4959
- const comp = new KatexComponent(textbus);
4936
+ const p = new ParagraphComponent();
4937
+ const comp = new KatexComponent();
4960
4938
  p.state.slot.insert(comp);
4961
4939
  insertComponent(p);
4962
4940
  selection.selectComponent(comp);
@@ -4964,17 +4942,17 @@ function InsertMenu(props) {
4964
4942
  break;
4965
4943
  case 'step':
4966
4944
  {
4967
- const step = new StepComponent(textbus, {
4945
+ const step = new StepComponent({
4968
4946
  step: 0,
4969
- items: [createStepItem(textbus)]
4947
+ items: [createStepItem()]
4970
4948
  });
4971
4949
  insertComponent(step);
4972
4950
  selection.selectFirstPosition(step, false, true);
4973
4951
  }
4974
4952
  break;
4975
4953
  case 'timeline': {
4976
- const timeline = new TimelineComponent(textbus, {
4977
- items: [createTimelineItem(textbus, '#296eff')]
4954
+ const timeline = new TimelineComponent({
4955
+ items: [createTimelineItem('#296eff')]
4978
4956
  });
4979
4957
  insertComponent(timeline);
4980
4958
  selection.selectFirstPosition(timeline, false, true);
@@ -5007,7 +4985,7 @@ function ItalicTool() {
5007
4985
  const query = inject(Query);
5008
4986
  const refreshService = inject(RefreshService);
5009
4987
  const textbus = inject(Textbus);
5010
- const [viewModel, update] = useProduce({
4988
+ const viewModel = reactive({
5011
4989
  highlight: false,
5012
4990
  });
5013
4991
  function toggle() {
@@ -5015,17 +4993,14 @@ function ItalicTool() {
5015
4993
  }
5016
4994
  const sub = refreshService.onRefresh.subscribe(() => {
5017
4995
  const state = query.queryFormat(italicFormatter);
5018
- update(draft => {
5019
- draft.highlight = state.state === QueryStateType.Enabled;
5020
- });
4996
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5021
4997
  });
5022
4998
  onUnmounted(() => {
5023
4999
  sub.unsubscribe();
5024
5000
  });
5025
5001
  const commonState = useCommonState();
5026
5002
  return () => {
5027
- const vm = viewModel();
5028
- 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" }) });
5029
5004
  };
5030
5005
  }
5031
5006
 
@@ -5134,7 +5109,7 @@ function StrikeThroughTool() {
5134
5109
  const query = inject(Query);
5135
5110
  const refreshService = inject(RefreshService);
5136
5111
  const textbus = inject(Textbus);
5137
- const [viewModel, update] = useProduce({
5112
+ const viewModel = reactive({
5138
5113
  highlight: false,
5139
5114
  });
5140
5115
  function toggle() {
@@ -5142,17 +5117,14 @@ function StrikeThroughTool() {
5142
5117
  }
5143
5118
  const sub = refreshService.onRefresh.subscribe(() => {
5144
5119
  const state = query.queryFormat(strikeThroughFormatter);
5145
- update(draft => {
5146
- draft.highlight = state.state === QueryStateType.Enabled;
5147
- });
5120
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5148
5121
  });
5149
5122
  onUnmounted(() => {
5150
5123
  sub.unsubscribe();
5151
5124
  });
5152
5125
  const commonState = useCommonState();
5153
5126
  return () => {
5154
- const vm = viewModel();
5155
- 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" }) });
5156
5128
  };
5157
5129
  }
5158
5130
 
@@ -5160,13 +5132,11 @@ function SubscriptTool() {
5160
5132
  const query = inject(Query);
5161
5133
  const selection = inject(Selection);
5162
5134
  const commander = inject(Commander);
5163
- const [state, updateState] = useProduce({
5135
+ const state = reactive({
5164
5136
  highlight: false
5165
5137
  });
5166
5138
  const sub = selection.onChange.subscribe(() => {
5167
- updateState(draft => {
5168
- draft.highlight = getState();
5169
- });
5139
+ state.highlight = getState();
5170
5140
  });
5171
5141
  function getState() {
5172
5142
  const s = query.queryFormat(subscriptFormatter);
@@ -5187,7 +5157,7 @@ function SubscriptTool() {
5187
5157
  }
5188
5158
  const commonState = useCommonState();
5189
5159
  return () => {
5190
- 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" }) }));
5191
5161
  };
5192
5162
  }
5193
5163
 
@@ -5195,13 +5165,11 @@ function SuperscriptTool() {
5195
5165
  const query = inject(Query);
5196
5166
  const selection = inject(Selection);
5197
5167
  const commander = inject(Commander);
5198
- const [state, updateState] = useProduce({
5168
+ const state = reactive({
5199
5169
  highlight: false
5200
5170
  });
5201
5171
  const sub = selection.onChange.subscribe(() => {
5202
- updateState(draft => {
5203
- draft.highlight = getState();
5204
- });
5172
+ state.highlight = getState();
5205
5173
  });
5206
5174
  function getState() {
5207
5175
  const s = query.queryFormat(superscriptFormatter);
@@ -5222,7 +5190,7 @@ function SuperscriptTool() {
5222
5190
  }
5223
5191
  const commonState = useCommonState();
5224
5192
  return () => {
5225
- 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" }) }));
5226
5194
  };
5227
5195
  }
5228
5196
 
@@ -5324,7 +5292,7 @@ function UnderlineTool() {
5324
5292
  const query = inject(Query);
5325
5293
  const refreshService = inject(RefreshService);
5326
5294
  const textbus = inject(Textbus);
5327
- const [viewModel, update] = useProduce({
5295
+ const viewModel = reactive({
5328
5296
  highlight: false,
5329
5297
  });
5330
5298
  function toggle() {
@@ -5332,17 +5300,14 @@ function UnderlineTool() {
5332
5300
  }
5333
5301
  const sub = refreshService.onRefresh.subscribe(() => {
5334
5302
  const state = query.queryFormat(underlineFormatter);
5335
- update(draft => {
5336
- draft.highlight = state.state === QueryStateType.Enabled;
5337
- });
5303
+ viewModel.highlight = state.state === QueryStateType.Enabled;
5338
5304
  });
5339
5305
  onUnmounted(() => {
5340
5306
  sub.unsubscribe();
5341
5307
  });
5342
5308
  const commonState = useCommonState();
5343
5309
  return () => {
5344
- const vm = viewModel();
5345
- 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" }) });
5346
5311
  };
5347
5312
  }
5348
5313
 
@@ -5534,7 +5499,7 @@ const cellBackgroundAttrLoader = {
5534
5499
  function CellBackgroundTool() {
5535
5500
  const refreshService = inject(RefreshService);
5536
5501
  const selection = inject(Selection);
5537
- const [viewModel, update] = useProduce({
5502
+ const viewModel = reactive({
5538
5503
  disabled: false,
5539
5504
  });
5540
5505
  function setColor(picker) {
@@ -5575,9 +5540,7 @@ function CellBackgroundTool() {
5575
5540
  }
5576
5541
  }
5577
5542
  const sub = refreshService.onRefresh.subscribe(() => {
5578
- update(draft => {
5579
- draft.disabled = !isInTable(selection);
5580
- });
5543
+ viewModel.disabled = !isInTable(selection);
5581
5544
  });
5582
5545
  onUnmounted(() => {
5583
5546
  sub.unsubscribe();
@@ -5593,8 +5556,7 @@ function CellBackgroundTool() {
5593
5556
  '#c596e0',
5594
5557
  ];
5595
5558
  return () => {
5596
- const vm = viewModel();
5597
- const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
5559
+ const d = viewModel.disabled || commonState().readonly || commonState().inSourceCode;
5598
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" }) }) }));
5599
5561
  };
5600
5562
  }
@@ -5602,7 +5564,7 @@ function CellBackgroundTool() {
5602
5564
  function MergeCellsTool() {
5603
5565
  const refreshService = inject(RefreshService);
5604
5566
  const selection = inject(Selection);
5605
- const [viewModel, update] = useProduce({
5567
+ const viewModel = reactive({
5606
5568
  highlight: false,
5607
5569
  disabled: false,
5608
5570
  });
@@ -5613,33 +5575,30 @@ function MergeCellsTool() {
5613
5575
  }
5614
5576
  }
5615
5577
  const sub = refreshService.onRefresh.subscribe(() => {
5616
- update(draft => {
5617
- const is = isInTable(selection);
5618
- if (is) {
5619
- const p1 = getTableSlotBySlot(selection.startSlot);
5620
- const p2 = getTableSlotBySlot(selection.endSlot);
5621
- if (p1 && p2) {
5622
- draft.disabled = p1 === p2;
5623
- return;
5624
- }
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;
5625
5585
  }
5626
- draft.disabled = true;
5627
- });
5586
+ }
5587
+ viewModel.disabled = true;
5628
5588
  });
5629
5589
  onUnmounted(() => {
5630
5590
  sub.unsubscribe();
5631
5591
  });
5632
5592
  const commonState = useCommonState();
5633
5593
  return () => {
5634
- const vm = viewModel();
5635
- 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" }) });
5636
5595
  };
5637
5596
  }
5638
5597
 
5639
5598
  function SplitCellsTool() {
5640
5599
  const refreshService = inject(RefreshService);
5641
5600
  const selection = inject(Selection);
5642
- const [viewModel, update] = useProduce({
5601
+ const viewModel = reactive({
5643
5602
  highlight: false,
5644
5603
  disabled: false,
5645
5604
  });
@@ -5664,47 +5623,44 @@ function SplitCellsTool() {
5664
5623
  }
5665
5624
  const sub = refreshService.onRefresh.subscribe(() => {
5666
5625
  const commonAncestorComponent = selection.commonAncestorComponent;
5667
- update(draft => {
5668
- if (commonAncestorComponent instanceof TableComponent) {
5669
- const slots = commonAncestorComponent.getSelectedNormalizedSlots();
5670
- if (slots) {
5671
- for (const item of slots) {
5672
- for (const cell of item.cells) {
5673
- if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
5674
- draft.disabled = false;
5675
- return;
5676
- }
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;
5677
5634
  }
5678
5635
  }
5679
5636
  }
5680
5637
  }
5681
- else {
5682
- let parentSlot = selection.commonAncestorSlot;
5683
- while (parentSlot) {
5684
- if (parentSlot.parent instanceof TableComponent) {
5685
- const slots = parentSlot.parent.getNormalizedData();
5686
- for (const item of slots) {
5687
- for (const cell of item.cells) {
5688
- if (cell.raw.slot === parentSlot) {
5689
- draft.disabled = !(cell.colspan > 1 || cell.colspan > 1);
5690
- return;
5691
- }
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;
5692
5649
  }
5693
5650
  }
5694
5651
  }
5695
- parentSlot = parentSlot.parentSlot;
5696
5652
  }
5653
+ parentSlot = parentSlot.parentSlot;
5697
5654
  }
5698
- draft.disabled = true;
5699
- });
5655
+ }
5656
+ viewModel.disabled = true;
5700
5657
  });
5701
5658
  onUnmounted(() => {
5702
5659
  sub.unsubscribe();
5703
5660
  });
5704
5661
  const commonState = useCommonState();
5705
5662
  return () => {
5706
- const vm = viewModel();
5707
- 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" }) });
5708
5664
  };
5709
5665
  }
5710
5666
 
@@ -5740,15 +5696,13 @@ const LeftToolbar = withAnnotation({
5740
5696
  refreshService.onRefresh.next();
5741
5697
  }
5742
5698
  }
5743
- const [positionSignal, updatePosition] = useProduce({
5699
+ const positionSignal = reactive({
5744
5700
  left: 0,
5745
5701
  top: 0,
5746
5702
  display: false
5747
5703
  });
5748
5704
  const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
5749
- updatePosition(d => {
5750
- d.display = editorService.canShowLeftToolbar;
5751
- });
5705
+ positionSignal.display = editorService.canShowLeftToolbar;
5752
5706
  });
5753
5707
  onUnmounted(() => {
5754
5708
  sub.unsubscribe();
@@ -5786,18 +5740,14 @@ const LeftToolbar = withAnnotation({
5786
5740
  slot.parent instanceof SourceCodeComponent ||
5787
5741
  slot.parent instanceof TableComponent);
5788
5742
  const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
5789
- updatePosition(draft => {
5790
- const containerRect = docContentContainer.getBoundingClientRect();
5791
- const currentRect = nativeNode.getBoundingClientRect();
5792
- draft.display = true;
5793
- draft.left = currentRect.left - containerRect.left;
5794
- draft.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
5795
- });
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;
5796
5748
  }
5797
5749
  else {
5798
- updatePosition(draft => {
5799
- draft.display = false;
5800
- });
5750
+ positionSignal.display = false;
5801
5751
  isEmptyBlock.set(false);
5802
5752
  }
5803
5753
  });
@@ -5876,7 +5826,6 @@ const LeftToolbar = withAnnotation({
5876
5826
  }
5877
5827
  return withScopedCSS(scopedId$a, () => {
5878
5828
  var _a;
5879
- const position = positionSignal();
5880
5829
  const slot = activeSlot();
5881
5830
  let activeNode = jsx("span", { class: "xnote-icon-pilcrow" });
5882
5831
  const states = checkStates(slot);
@@ -5906,9 +5855,9 @@ const LeftToolbar = withAnnotation({
5906
5855
  const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
5907
5856
  const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
5908
5857
  return (jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
5909
- left: position.left + 'px',
5910
- top: position.top + 'px',
5911
- 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'
5912
5861
  }, children: jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
5913
5862
  position: 'absolute',
5914
5863
  right: 0,
@@ -6036,14 +5985,14 @@ const InlineToolbar = withAnnotation({
6036
5985
  const subscription = merge(textbus.onChange, selection.onChange).pipe(debounceTime(20), tap(() => {
6037
5986
  refreshService.onRefresh.next();
6038
5987
  }), delay(200)).subscribe(() => {
6039
- if (viewPosition().isHide) {
5988
+ if (viewPosition.isHide) {
6040
5989
  editorService.changeLeftToolbarVisible(true);
6041
5990
  }
6042
5991
  });
6043
5992
  onUnmounted(() => {
6044
5993
  subscription.unsubscribe();
6045
5994
  });
6046
- const [viewPosition, updateViewPosition] = useProduce({
5995
+ const viewPosition = reactive({
6047
5996
  left: 0,
6048
5997
  top: 0,
6049
5998
  isHide: true,
@@ -6121,21 +6070,17 @@ const InlineToolbar = withAnnotation({
6121
6070
  const top = toBottom ?
6122
6071
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
6123
6072
  selectionFocusRect.top - docRect.top - toolbarHeight - 10;
6124
- updateViewPosition(draft => {
6125
- draft.transitionDuration = .15;
6126
- draft.left = centerLeft - docRect.left;
6127
- // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
6128
- draft.top = top + 10;
6129
- });
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;
6130
6077
  return top;
6131
6078
  }
6132
6079
  const sub = textbus.onChange.pipe(debounceTime(100)).subscribe(() => {
6133
- if (!viewPosition().isHide) {
6080
+ if (!viewPosition.isHide) {
6134
6081
  const top = getTop();
6135
6082
  if (top !== null && !selection.isCollapsed) {
6136
- updateViewPosition(draft => {
6137
- draft.top = top;
6138
- });
6083
+ viewPosition.top = top;
6139
6084
  return;
6140
6085
  }
6141
6086
  }
@@ -6158,11 +6103,9 @@ const InlineToolbar = withAnnotation({
6158
6103
  return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
6159
6104
  }), map(getTop), delay(200)).subscribe((top) => {
6160
6105
  if (top !== null) {
6161
- updateViewPosition(draft => {
6162
- draft.isHide = false;
6163
- draft.opacity = 1;
6164
- draft.top = top;
6165
- });
6106
+ viewPosition.isHide = false;
6107
+ viewPosition.opacity = 1;
6108
+ viewPosition.top = top;
6166
6109
  editorService.changeLeftToolbarVisible(false);
6167
6110
  }
6168
6111
  else {
@@ -6175,11 +6118,9 @@ const InlineToolbar = withAnnotation({
6175
6118
  return;
6176
6119
  }
6177
6120
  mouseupSubscription.unsubscribe();
6178
- updateViewPosition(draft => {
6179
- draft.opacity = 0;
6180
- draft.isHide = true;
6181
- draft.transitionDuration = 0;
6182
- });
6121
+ viewPosition.opacity = 0;
6122
+ viewPosition.isHide = true;
6123
+ viewPosition.transitionDuration = 0;
6183
6124
  bindMouseup();
6184
6125
  });
6185
6126
  const instance = getCurrentInstance();
@@ -6192,14 +6133,13 @@ const InlineToolbar = withAnnotation({
6192
6133
  mouseupSubscription.unsubscribe();
6193
6134
  });
6194
6135
  return withScopedCSS(scopedId$8, () => {
6195
- const p = viewPosition();
6196
6136
  return (jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
6197
- left: p.left + 'px',
6198
- top: p.top + 'px',
6199
- pointerEvents: p.isHide ? 'none' : 'initial',
6200
- opacity: p.opacity,
6137
+ left: viewPosition.left + 'px',
6138
+ top: viewPosition.top + 'px',
6139
+ pointerEvents: viewPosition.isHide ? 'none' : 'initial',
6140
+ opacity: viewPosition.opacity,
6201
6141
  display: editorService.hideInlineToolbar ? 'none' : '',
6202
- transitionDuration: p.transitionDuration + 's'
6142
+ transitionDuration: viewPosition.transitionDuration + 's'
6203
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")] }));
6204
6144
  });
6205
6145
  });
@@ -6287,10 +6227,11 @@ class StaticToolbarPlugin {
6287
6227
  const container = document.createElement('div');
6288
6228
  container.style.position = 'relative';
6289
6229
  container.style.borderRadius = 'inherit';
6290
- this.app = createApp(jsx(Context, { providers: [{
6291
- provide: DropdownMenuContainer,
6292
- useValue: container
6293
- }], 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 }) }), {
6294
6235
  context: injector
6295
6236
  });
6296
6237
  this.options.host.appendChild(container);
@@ -6322,39 +6263,30 @@ const SuspensionToolbar = withAnnotation({
6322
6263
  onUnmounted(() => {
6323
6264
  subscription.unsubscribe();
6324
6265
  });
6325
- const [styles, updateStyles] = useProduce({
6266
+ const styles = reactive({
6326
6267
  top: 0,
6327
6268
  opacity: 1,
6328
6269
  });
6329
6270
  subscription.add(fromEvent(document, 'scroll').pipe(tap(() => {
6330
- updateStyles(draft => {
6331
- draft.opacity = 0;
6332
- });
6271
+ styles.opacity = 0;
6333
6272
  }), debounceTime(100), tap(() => {
6334
6273
  const rect = viewDocument.getBoundingClientRect();
6335
6274
  if (rect.top < 10) {
6336
- updateStyles(draft => {
6337
- draft.top = Math.min(-rect.top + 10, rect.height - 100);
6338
- });
6275
+ styles.top = Math.min(-rect.top + 10, rect.height - 100);
6339
6276
  }
6340
6277
  else {
6341
- updateStyles(draft => {
6342
- draft.top = 0;
6343
- });
6278
+ styles.top = 0;
6344
6279
  }
6345
6280
  }), delay(100)).subscribe(() => {
6346
- updateStyles(draft => {
6347
- draft.opacity = 1;
6348
- });
6281
+ styles.opacity = 1;
6349
6282
  }));
6350
6283
  return withScopedCSS(scopedId$6, () => {
6351
- const s = styles();
6352
6284
  return (jsxs("div", { class: ['toolbar', props.theme, {
6353
- suspension: s.top === 0 ? '' : 'suspension'
6285
+ suspension: styles.top === 0 ? '' : 'suspension'
6354
6286
  }], style: {
6355
- top: s.top + 'px',
6356
- opacity: s.opacity,
6357
- pointerEvents: s.opacity === 0 ? 'none' : 'initial',
6287
+ top: styles.top + 'px',
6288
+ opacity: styles.opacity,
6289
+ pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
6358
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")] }));
6359
6291
  });
6360
6292
  });
@@ -6537,7 +6469,7 @@ function registerAtShortcut(textbus) {
6537
6469
  if (commonAncestorComponent instanceof SourceCodeComponent) {
6538
6470
  return false;
6539
6471
  }
6540
- const at = new AtComponent(textbus);
6472
+ const at = new AtComponent();
6541
6473
  commander.insert(at);
6542
6474
  selection.setPosition(at.state.slot, 0);
6543
6475
  }
@@ -6548,21 +6480,21 @@ class AtComponent extends Component {
6548
6480
  const registry = textbus.get(Registry);
6549
6481
  if (slotState) {
6550
6482
  const slot = registry.createSlot(slotState);
6551
- return new AtComponent(textbus, {
6483
+ return new AtComponent({
6552
6484
  slot
6553
6485
  });
6554
6486
  }
6555
- return new AtComponent(textbus, {
6487
+ return new AtComponent({
6556
6488
  userInfo,
6557
6489
  });
6558
6490
  }
6559
- constructor(textbus, state = {
6491
+ constructor(state = {
6560
6492
  slot: new Slot([ContentType.Text])
6561
6493
  }) {
6562
6494
  if (!state.userInfo && !state.slot) {
6563
6495
  state.slot = new Slot([ContentType.Text]);
6564
6496
  }
6565
- super(textbus, state);
6497
+ super(state);
6566
6498
  Object.defineProperty(this, "focus", {
6567
6499
  enumerable: true,
6568
6500
  configurable: true,
@@ -6585,13 +6517,13 @@ class AtComponent extends Component {
6585
6517
  enumerable: true,
6586
6518
  configurable: true,
6587
6519
  writable: true,
6588
- value: this.textbus.get(Selection)
6520
+ value: void 0
6589
6521
  });
6590
6522
  Object.defineProperty(this, "organization", {
6591
6523
  enumerable: true,
6592
6524
  configurable: true,
6593
6525
  writable: true,
6594
- value: this.textbus.get(Organization)
6526
+ value: void 0
6595
6527
  });
6596
6528
  }
6597
6529
  getSlots() {
@@ -6604,6 +6536,8 @@ class AtComponent extends Component {
6604
6536
  return [];
6605
6537
  }
6606
6538
  setup() {
6539
+ this.selection = useContext(Selection);
6540
+ this.organization = useContext(Organization);
6607
6541
  let isFocus = false;
6608
6542
  onFocus(() => {
6609
6543
  isFocus = true;
@@ -6678,7 +6612,7 @@ class AtComponent extends Component {
6678
6612
  this.focus.next(true);
6679
6613
  }
6680
6614
  });
6681
- onDestroy(() => {
6615
+ onDetach(() => {
6682
6616
  subs.unsubscribe();
6683
6617
  });
6684
6618
  }
@@ -6768,12 +6702,12 @@ const atComponentLoader = {
6768
6702
  read(element, textbus, slotParser) {
6769
6703
  const data = element.dataset.info;
6770
6704
  if (data) {
6771
- return new AtComponent(textbus, {
6705
+ return new AtComponent({
6772
6706
  userInfo: JSON.parse(decodeURIComponent(data))
6773
6707
  });
6774
6708
  }
6775
6709
  const slot = slotParser(new Slot([ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
6776
- return new AtComponent(textbus, {
6710
+ return new AtComponent({
6777
6711
  slot
6778
6712
  });
6779
6713
  }
@@ -6791,7 +6725,7 @@ class RootComponent extends Component {
6791
6725
  }
6792
6726
  static fromJSON(textbus, json) {
6793
6727
  const content = textbus.get(Registry).createSlot(json.content);
6794
- return new RootComponent(textbus, {
6728
+ return new RootComponent({
6795
6729
  content
6796
6730
  });
6797
6731
  }
@@ -6820,7 +6754,7 @@ class RootComponent extends Component {
6820
6754
  }
6821
6755
  const selection = this.textbus.get(Selection);
6822
6756
  content.retain(content.length);
6823
- const newParagraph = new ParagraphComponent(this.textbus);
6757
+ const newParagraph = new ParagraphComponent();
6824
6758
  content.insert(newParagraph);
6825
6759
  selection.setPosition(newParagraph.state.slot, 0);
6826
6760
  }
@@ -6869,7 +6803,7 @@ const rootComponentLoader = {
6869
6803
  match() {
6870
6804
  return true;
6871
6805
  },
6872
- read(element, textbus, slotParser) {
6806
+ read(element, _, slotParser) {
6873
6807
  const delta = slotParser(new Slot([
6874
6808
  ContentType.BlockComponent,
6875
6809
  ContentType.InlineComponent,
@@ -6878,7 +6812,7 @@ const rootComponentLoader = {
6878
6812
  const slot = new Slot([
6879
6813
  ContentType.BlockComponent
6880
6814
  ]);
6881
- deltaToBlock(delta, textbus).forEach(i => {
6815
+ deltaToBlock(delta).forEach(i => {
6882
6816
  slot.insert(i);
6883
6817
  });
6884
6818
  return slot;
@@ -7124,7 +7058,7 @@ function Scroll(props) {
7124
7058
  const scrollRef = createRef();
7125
7059
  const input = inject(Input);
7126
7060
  const tableService = inject(TableService);
7127
- const [showShadow, updateShowShadow] = useProduce({
7061
+ const showShadow = reactive({
7128
7062
  leftEnd: false,
7129
7063
  rightEnd: false
7130
7064
  });
@@ -7134,10 +7068,8 @@ function Scroll(props) {
7134
7068
  if (props.isFocus()) {
7135
7069
  input.caret.refresh();
7136
7070
  }
7137
- updateShowShadow(draft => {
7138
- draft.leftEnd = el.scrollLeft === 0;
7139
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7140
- });
7071
+ showShadow.leftEnd = el.scrollLeft === 0;
7072
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7141
7073
  }
7142
7074
  update();
7143
7075
  const s = fromEvent(el, 'scroll').subscribe(update);
@@ -7145,15 +7077,13 @@ function Scroll(props) {
7145
7077
  });
7146
7078
  onUpdated(() => {
7147
7079
  const el = scrollRef.current;
7148
- updateShowShadow(draft => {
7149
- draft.leftEnd = el.scrollLeft === 0;
7150
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7151
- });
7080
+ showShadow.leftEnd = el.scrollLeft === 0;
7081
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7152
7082
  });
7153
7083
  return withScopedCSS(scopedId$3, () => {
7154
7084
  return jsx("div", { ref: [scrollRef], class: ['scroll-container', {
7155
- 'left-end': showShadow().leftEnd,
7156
- 'right-end': showShadow().rightEnd,
7085
+ 'left-end': showShadow.leftEnd,
7086
+ 'right-end': showShadow.rightEnd,
7157
7087
  'active': props.isFocus(),
7158
7088
  // 'hide-selection': isSelectColumn()
7159
7089
  }], onScroll: ev => {
@@ -7296,34 +7226,30 @@ var scopedId$1 = "vf-d4c4a9";
7296
7226
  function ResizeRow(props) {
7297
7227
  const dragLineRef = createRef();
7298
7228
  const tableService = inject(TableService);
7299
- const [styles, updateStyles] = useProduce({
7229
+ const styles = reactive({
7300
7230
  visible: false,
7301
7231
  top: 0
7302
7232
  });
7303
7233
  onMounted(() => {
7304
7234
  const sub = tableService.onInsertRowBefore.subscribe(i => {
7305
7235
  if (i === null) {
7306
- updateStyles(draft => {
7307
- draft.visible = false;
7308
- });
7236
+ styles.visible = false;
7309
7237
  return;
7310
7238
  }
7311
- updateStyles(draft => {
7312
- draft.visible = true;
7313
- if (i === -1) {
7314
- draft.top = 0;
7315
- return;
7316
- }
7317
- const row = props.tableRef.current.rows.item(i);
7318
- draft.top = row.offsetTop + row.offsetHeight;
7319
- });
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;
7320
7246
  });
7321
7247
  return () => sub.unsubscribe();
7322
7248
  });
7323
7249
  return withScopedCSS(scopedId$1, () => {
7324
7250
  return jsx("div", { ref: dragLineRef, style: {
7325
- display: styles().visible ? 'block' : 'none',
7326
- top: styles().top + 'px',
7251
+ display: styles.visible ? 'block' : 'none',
7252
+ top: styles.top + 'px',
7327
7253
  width: sum(props.component.state.columnsConfig) + 'px'
7328
7254
  }, class: 'drag-line' });
7329
7255
  });
@@ -7332,7 +7258,7 @@ function ResizeRow(props) {
7332
7258
  var scopedId = "vf-4a5ad1";
7333
7259
 
7334
7260
  function SelectionMask(props) {
7335
- const [styles, updateStyles] = useProduce({
7261
+ const styles = reactive({
7336
7262
  visible: false,
7337
7263
  left: 0,
7338
7264
  top: 0,
@@ -7346,6 +7272,7 @@ function SelectionMask(props) {
7346
7272
  });
7347
7273
  watch(props.component.tableSelection, update);
7348
7274
  function update() {
7275
+ var _a;
7349
7276
  const selection = props.component.tableSelection();
7350
7277
  const state = props.component.state;
7351
7278
  if (isShowMask(props.component)) {
@@ -7362,21 +7289,16 @@ function SelectionMask(props) {
7362
7289
  heightCompensation += 0.5;
7363
7290
  }
7364
7291
  const trs = Array.from(props.tableRef.current.rows);
7365
- updateStyles(draft => {
7366
- var _a;
7367
- const height = trs[selection.endRow - 1].offsetHeight ||
7368
- ((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
7369
- draft.visible = true;
7370
- draft.left = sum(state.columnsConfig.slice(0, selection.startColumn));
7371
- draft.top = trs[selection.startRow].offsetTop + topCompensation;
7372
- draft.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
7373
- draft.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - draft.top + 'px';
7374
- });
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';
7375
7299
  }
7376
7300
  else {
7377
- updateStyles(draft => {
7378
- draft.visible = false;
7379
- });
7301
+ styles.visible = false;
7380
7302
  }
7381
7303
  }
7382
7304
  const s = props.component.changeMarker.onChange.pipe(debounceTime(30)).subscribe(() => {
@@ -7386,15 +7308,14 @@ function SelectionMask(props) {
7386
7308
  s.unsubscribe();
7387
7309
  });
7388
7310
  return withScopedCSS(scopedId, () => {
7389
- const style = styles();
7390
7311
  return (jsx("div", { class: "mask", style: {
7391
- display: style.visible ? 'block' : 'none',
7392
- left: style.left + 'px',
7393
- top: style.top + 'px',
7394
- right: style.right + 'px',
7395
- width: style.width,
7396
- height: style.height,
7397
- 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'
7398
7319
  } }));
7399
7320
  });
7400
7321
  }
@@ -7609,7 +7530,7 @@ const tableComponentLoader = {
7609
7530
  ContentType.InlineComponent,
7610
7531
  ContentType.Text
7611
7532
  ]), cell).toDelta();
7612
- const results = deltaToBlock(delta, textbus);
7533
+ const results = deltaToBlock(delta);
7613
7534
  delta.attributes.forEach((value, key) => {
7614
7535
  slot.setAttribute(key, value);
7615
7536
  });
@@ -7640,7 +7561,7 @@ const tableComponentLoader = {
7640
7561
  ContentType.InlineComponent,
7641
7562
  ContentType.Text
7642
7563
  ]), cell).toDelta();
7643
- const results = deltaToBlock(delta, textbus);
7564
+ const results = deltaToBlock(delta);
7644
7565
  delta.attributes.forEach((value, key) => {
7645
7566
  slot.setAttribute(key, value);
7646
7567
  });
@@ -7667,7 +7588,7 @@ const tableComponentLoader = {
7667
7588
  layoutWidth[i] = layoutWidth[i] || 100;
7668
7589
  }
7669
7590
  layoutWidth.length = length;
7670
- return new TableComponent(textbus, {
7591
+ return new TableComponent({
7671
7592
  columnsConfig: layoutWidth,
7672
7593
  mergeConfig: cells.mergedConfig,
7673
7594
  rows: cells.table.map(i => {
@@ -7756,7 +7677,6 @@ TableSelectionAwarenessDelegate = __decorate([
7756
7677
 
7757
7678
  function TimelineComponentView(props) {
7758
7679
  const adapter = inject(DomAdapter);
7759
- const textbus = inject(Textbus);
7760
7680
  const isOutput = useOutput();
7761
7681
  const isReadonly = useReadonly();
7762
7682
  return () => {
@@ -7769,7 +7689,7 @@ function TimelineComponentView(props) {
7769
7689
  backgroundColor: item.theme,
7770
7690
  } }), !isOutput() && !isReadonly() && jsxs("div", { class: "xnote-timeline-tools", children: [jsx(Button, { class: "xnote-timeline-add xnote-icon-plus", onClick: () => {
7771
7691
  const index = component.state.items.indexOf(item) + 1;
7772
- component.state.items.splice(index, 0, createTimelineItem(textbus, item.theme));
7692
+ component.state.items.splice(index, 0, createTimelineItem(item.theme));
7773
7693
  } }), jsx(Button, { class: "xnote-timeline-add xnote-icon-bin", onClick: () => {
7774
7694
  const index = component.state.items.indexOf(item);
7775
7695
  component.state.items.splice(index, 1);
@@ -7785,8 +7705,8 @@ const timelineComponentLoader = {
7785
7705
  match(element) {
7786
7706
  return element.className === 'xnote-timeline';
7787
7707
  },
7788
- read(element, context, slotParser) {
7789
- return new TimelineComponent(context, {
7708
+ read(element, _, slotParser) {
7709
+ return new TimelineComponent({
7790
7710
  items: Array.from(element.children).map(child => {
7791
7711
  const slot = new Slot([
7792
7712
  ContentType.BlockComponent
@@ -7802,7 +7722,6 @@ const timelineComponentLoader = {
7802
7722
 
7803
7723
  function StepComponentView(props) {
7804
7724
  const adapter = inject(DomAdapter);
7805
- const textbus = inject(Textbus);
7806
7725
  const isOutput = useOutput();
7807
7726
  const isReadonly = useReadonly();
7808
7727
  return () => {
@@ -7828,7 +7747,7 @@ function StepComponentView(props) {
7828
7747
  }
7829
7748
  }, children: index + 1 })] }), !isOutput() && !isReadonly() && jsxs("div", { class: "xnote-step-tools", children: [jsx(Button, { class: "xnote-step-add xnote-icon-plus", onClick: () => {
7830
7749
  const index = component.state.items.indexOf(item) + 1;
7831
- component.state.items.splice(index, 0, createStepItem(textbus));
7750
+ component.state.items.splice(index, 0, createStepItem());
7832
7751
  } }), jsx(Button, { class: "xnote-step-add xnote-icon-bin", onClick: () => {
7833
7752
  const index = component.state.items.indexOf(item);
7834
7753
  component.state.items.splice(index, 1);
@@ -7844,8 +7763,8 @@ const stepComponentLoader = {
7844
7763
  match(element) {
7845
7764
  return element.dataset.component === StepComponent.componentName;
7846
7765
  },
7847
- read(element, context, slotParser) {
7848
- return new StepComponent(context, {
7766
+ read(element, _, slotParser) {
7767
+ return new StepComponent({
7849
7768
  step: Number(element.dataset.step) || 0,
7850
7769
  items: Array.from(element.children).map(child => {
7851
7770
  const slot = new Slot([
@@ -8127,7 +8046,7 @@ class Editor extends Textbus {
8127
8046
  rootComp = this.createModel(config.content);
8128
8047
  }
8129
8048
  else {
8130
- rootComp = new RootComponent(this, {
8049
+ rootComp = new RootComponent({
8131
8050
  content: new Slot([ContentType.BlockComponent])
8132
8051
  });
8133
8052
  }
@@ -8163,11 +8082,11 @@ class Editor extends Textbus {
8163
8082
  ContentType.BlockComponent
8164
8083
  ]);
8165
8084
  if (doc instanceof Slot) {
8166
- deltaToBlock(doc.toDelta(), this).forEach(i => {
8085
+ deltaToBlock(doc.toDelta()).forEach(i => {
8167
8086
  content.insert(i);
8168
8087
  });
8169
8088
  }
8170
- return new RootComponent(this, {
8089
+ return new RootComponent({
8171
8090
  content
8172
8091
  });
8173
8092
  }