@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.
package/bundles/index.js CHANGED
@@ -7,7 +7,6 @@ var core$1 = require('@textbus/core');
7
7
  var color = require('@tanbo/color');
8
8
  var platformBrowser = require('@textbus/platform-browser');
9
9
  var platformBrowser$1 = require('@viewfly/platform-browser');
10
- var hooks = require('@viewfly/hooks');
11
10
  var highlightjs = require('highlight.js');
12
11
  var uuid = require('uuid');
13
12
  var Katex = require('katex');
@@ -1166,7 +1165,7 @@ function useBlockContent(slot) {
1166
1165
  const selection = textbus.get(core$1.Selection);
1167
1166
  core$1.onBreak(ev => {
1168
1167
  if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
1169
- const p = new ParagraphComponent(textbus);
1168
+ const p = new ParagraphComponent();
1170
1169
  ev.target.insert(p);
1171
1170
  selection.setPosition(p.state.slot, 0);
1172
1171
  ev.preventDefault();
@@ -1175,7 +1174,7 @@ function useBlockContent(slot) {
1175
1174
  core$1.onContentInsert(ev => {
1176
1175
  if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
1177
1176
  (typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
1178
- const p = new ParagraphComponent(textbus);
1177
+ const p = new ParagraphComponent();
1179
1178
  const childSlot = p.state.slot;
1180
1179
  childSlot.insert(ev.data.content);
1181
1180
  ev.target.insert(p);
@@ -1197,10 +1196,12 @@ function SlotRender(props) {
1197
1196
  });
1198
1197
  }
1199
1198
  let sub = listen(slot);
1200
- core.onPropsChanged((currentProps, oldProps) => {
1201
- if (oldProps.slot !== currentProps.slot) {
1199
+ core.watch(() => {
1200
+ return props.slot;
1201
+ }, (currentSlot, oldSlot) => {
1202
+ if (oldSlot !== currentSlot) {
1202
1203
  sub.unsubscribe();
1203
- sub = listen(currentProps.slot);
1204
+ sub = listen(currentSlot);
1204
1205
  }
1205
1206
  });
1206
1207
  core.onUnmounted(() => {
@@ -1217,16 +1218,16 @@ function SlotRender(props) {
1217
1218
  class BlockquoteComponent extends core$1.Component {
1218
1219
  static fromJSON(textbus, json) {
1219
1220
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
1220
- return new BlockquoteComponent(textbus, {
1221
+ return new BlockquoteComponent({
1221
1222
  slot
1222
1223
  });
1223
1224
  }
1224
- constructor(textbus, state = {
1225
+ constructor(state = {
1225
1226
  slot: new core$1.Slot([
1226
1227
  core$1.ContentType.BlockComponent
1227
1228
  ])
1228
1229
  }) {
1229
- super(textbus, state);
1230
+ super(state);
1230
1231
  }
1231
1232
  getSlots() {
1232
1233
  return [this.state.slot];
@@ -1291,7 +1292,7 @@ function toBlockquote(textbus) {
1291
1292
  });
1292
1293
  }
1293
1294
  else {
1294
- const block = new BlockquoteComponent(textbus);
1295
+ const block = new BlockquoteComponent();
1295
1296
  const slot = block.state.slot;
1296
1297
  if (selection.startSlot === selection.endSlot) {
1297
1298
  const parentComponent = selection.startSlot.parent;
@@ -1336,7 +1337,7 @@ const blockquoteComponentLoader = {
1336
1337
  match(element, returnableContentTypes) {
1337
1338
  return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
1338
1339
  },
1339
- read(element, textbus, slotParser) {
1340
+ read(element, _, slotParser) {
1340
1341
  const delta = slotParser(new core$1.Slot([
1341
1342
  core$1.ContentType.BlockComponent,
1342
1343
  core$1.ContentType.InlineComponent,
@@ -1345,10 +1346,10 @@ const blockquoteComponentLoader = {
1345
1346
  const slot = new core$1.Slot([
1346
1347
  core$1.ContentType.BlockComponent,
1347
1348
  ]);
1348
- deltaToBlock(delta, textbus).forEach(i => {
1349
+ deltaToBlock(delta).forEach(i => {
1349
1350
  slot.insert(i);
1350
1351
  });
1351
- return new BlockquoteComponent(textbus, {
1352
+ return new BlockquoteComponent({
1352
1353
  slot
1353
1354
  });
1354
1355
  },
@@ -1356,18 +1357,18 @@ const blockquoteComponentLoader = {
1356
1357
 
1357
1358
  class HighlightBoxComponent extends core$1.Component {
1358
1359
  static fromJSON(textbus, json) {
1359
- return new HighlightBoxComponent(textbus, {
1360
+ return new HighlightBoxComponent({
1360
1361
  type: json.type,
1361
1362
  slot: textbus.get(core$1.Registry).createSlot(json.slot)
1362
1363
  });
1363
1364
  }
1364
- constructor(textbus, state = {
1365
+ constructor(state = {
1365
1366
  type: '',
1366
1367
  slot: new core$1.Slot([
1367
1368
  core$1.ContentType.BlockComponent,
1368
1369
  ])
1369
1370
  }) {
1370
- super(textbus, state);
1371
+ super(state);
1371
1372
  }
1372
1373
  getSlots() {
1373
1374
  return [this.state.slot];
@@ -1433,10 +1434,10 @@ const highlightBoxComponentLoader = {
1433
1434
  const slot = new core$1.Slot([
1434
1435
  core$1.ContentType.BlockComponent,
1435
1436
  ]);
1436
- deltaToBlock(delta, textbus).forEach(i => {
1437
+ deltaToBlock(delta).forEach(i => {
1437
1438
  slot.insert(i);
1438
1439
  });
1439
- return new HighlightBoxComponent(textbus, {
1440
+ return new HighlightBoxComponent({
1440
1441
  type: element.dataset.icon || '',
1441
1442
  slot
1442
1443
  });
@@ -1531,11 +1532,11 @@ const colorFormatLoader = {
1531
1532
  }
1532
1533
  };
1533
1534
 
1534
- function createTimelineItem(textbus, theme) {
1535
+ function createTimelineItem(theme) {
1535
1536
  const slot = new core$1.Slot([
1536
1537
  core$1.ContentType.BlockComponent,
1537
1538
  ]);
1538
- const title = new ParagraphComponent(textbus);
1539
+ const title = new ParagraphComponent();
1539
1540
  title.state.slot.insert('时间主题', [
1540
1541
  [fontSizeFormatter, '18px'],
1541
1542
  [boldFormatter, true]
@@ -1544,7 +1545,7 @@ function createTimelineItem(textbus, theme) {
1544
1545
  [fontSizeFormatter, '15px'],
1545
1546
  [colorFormatter, '#777']
1546
1547
  ]);
1547
- const desc = new ParagraphComponent(textbus);
1548
+ const desc = new ParagraphComponent();
1548
1549
  desc.state.slot.insert('描述信息...');
1549
1550
  slot.insert(title);
1550
1551
  slot.insert(desc);
@@ -1553,7 +1554,7 @@ function createTimelineItem(textbus, theme) {
1553
1554
  class TimelineComponent extends core$1.Component {
1554
1555
  static fromJSON(textbus, json) {
1555
1556
  const registry = textbus.get(core$1.Registry);
1556
- return new TimelineComponent(textbus, {
1557
+ return new TimelineComponent({
1557
1558
  items: json.items.map(i => {
1558
1559
  return {
1559
1560
  theme: i.theme,
@@ -1587,16 +1588,16 @@ Object.defineProperty(TimelineComponent, "type", {
1587
1588
  value: core$1.ContentType.BlockComponent
1588
1589
  });
1589
1590
 
1590
- function createStepItem(textbus) {
1591
+ function createStepItem() {
1591
1592
  const slot = new core$1.Slot([
1592
1593
  core$1.ContentType.BlockComponent
1593
1594
  ]);
1594
- const title = new ParagraphComponent(textbus);
1595
+ const title = new ParagraphComponent();
1595
1596
  title.state.slot.insert('标题', [
1596
1597
  [fontSizeFormatter, '18px'],
1597
1598
  [boldFormatter, true]
1598
1599
  ]);
1599
- const content = new ParagraphComponent(textbus);
1600
+ const content = new ParagraphComponent();
1600
1601
  content.state.slot.insert('描述信息...');
1601
1602
  slot.insert(title);
1602
1603
  slot.insert(content);
@@ -1605,7 +1606,7 @@ function createStepItem(textbus) {
1605
1606
  class StepComponent extends core$1.Component {
1606
1607
  static fromJSON(textbus, json) {
1607
1608
  const registry = textbus.get(core$1.Registry);
1608
- return new StepComponent(textbus, {
1609
+ return new StepComponent({
1609
1610
  step: json.step,
1610
1611
  items: json.items.map(i => {
1611
1612
  return {
@@ -1645,17 +1646,17 @@ Object.defineProperty(StepComponent, "type", {
1645
1646
  class ParagraphComponent extends core$1.Component {
1646
1647
  static fromJSON(textbus, json) {
1647
1648
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
1648
- return new ParagraphComponent(textbus, {
1649
+ return new ParagraphComponent({
1649
1650
  slot
1650
1651
  });
1651
1652
  }
1652
- constructor(textbus, state = {
1653
+ constructor(state = {
1653
1654
  slot: new core$1.Slot([
1654
1655
  core$1.ContentType.InlineComponent,
1655
1656
  core$1.ContentType.Text
1656
1657
  ])
1657
1658
  }) {
1658
- super(textbus, state);
1659
+ super(state);
1659
1660
  }
1660
1661
  getSlots() {
1661
1662
  return [this.state.slot];
@@ -1668,7 +1669,7 @@ class ParagraphComponent extends core$1.Component {
1668
1669
  const isEmpty = this.state.slot.isEmpty;
1669
1670
  const afterSlot = ev.target.cut(ev.data.index);
1670
1671
  afterSlot.removeAttribute(headingAttr);
1671
- const nextParagraph = new ParagraphComponent(injector, {
1672
+ const nextParagraph = new ParagraphComponent({
1672
1673
  slot: afterSlot
1673
1674
  });
1674
1675
  if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
@@ -1711,7 +1712,7 @@ const paragraphComponentLoader = {
1711
1712
  return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
1712
1713
  (element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
1713
1714
  },
1714
- read(element, textbus, slotParser) {
1715
+ read(element, _, slotParser) {
1715
1716
  let content;
1716
1717
  if (/^P|H[1-6]$/.test(element.tagName)) {
1717
1718
  content = element;
@@ -1729,7 +1730,7 @@ const paragraphComponentLoader = {
1729
1730
  core$1.ContentType.InlineComponent,
1730
1731
  core$1.ContentType.BlockComponent
1731
1732
  ]), content).toDelta();
1732
- const results = deltaToBlock(delta, textbus);
1733
+ const results = deltaToBlock(delta);
1733
1734
  if (results.length === 1) {
1734
1735
  return results[0];
1735
1736
  }
@@ -1742,7 +1743,7 @@ const paragraphComponentLoader = {
1742
1743
  return containerSlot;
1743
1744
  }
1744
1745
  };
1745
- function deltaToBlock(delta, textbus) {
1746
+ function deltaToBlock(delta) {
1746
1747
  const results = [];
1747
1748
  let slot = null;
1748
1749
  for (const item of delta) {
@@ -1755,7 +1756,7 @@ function deltaToBlock(delta, textbus) {
1755
1756
  delta.attributes.forEach((value, key) => {
1756
1757
  slot.setAttribute(key, value);
1757
1758
  });
1758
- results.push(new ParagraphComponent(textbus, {
1759
+ results.push(new ParagraphComponent({
1759
1760
  slot
1760
1761
  }));
1761
1762
  }
@@ -1920,7 +1921,7 @@ class SourceCodeComponent extends core$1.Component {
1920
1921
  }
1921
1922
  static fromJSON(textbus, json) {
1922
1923
  const registry = textbus.get(core$1.Registry);
1923
- return new SourceCodeComponent(textbus, {
1924
+ return new SourceCodeComponent({
1924
1925
  slots: json.slots.map(item => {
1925
1926
  return {
1926
1927
  slot: registry.createSlot(item.slot),
@@ -1950,7 +1951,7 @@ class SourceCodeComponent extends core$1.Component {
1950
1951
  core$1.ContentType.InlineComponent,
1951
1952
  core$1.ContentType.Text
1952
1953
  ]);
1953
- const paragraph = new ParagraphComponent(textbus, {
1954
+ const paragraph = new ParagraphComponent({
1954
1955
  slot
1955
1956
  });
1956
1957
  const index = parentSlot.indexOf(parentComponent);
@@ -2325,7 +2326,7 @@ const sourceCodeComponentLoader = {
2325
2326
  ((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
2326
2327
  element.tagName === 'PRE');
2327
2328
  },
2328
- read(el, textbus) {
2329
+ read(el) {
2329
2330
  let slots = [];
2330
2331
  if (el.tagName === 'DIV') {
2331
2332
  const lines = el.querySelectorAll('.xnote-source-code-line');
@@ -2348,7 +2349,7 @@ const sourceCodeComponentLoader = {
2348
2349
  return item;
2349
2350
  });
2350
2351
  }
2351
- return new SourceCodeComponent(textbus, {
2352
+ return new SourceCodeComponent({
2352
2353
  lang: el.dataset.lang || '',
2353
2354
  theme: el.dataset.theme || '',
2354
2355
  lineNumber: el.dataset.lineNumber === 'true',
@@ -2443,7 +2444,7 @@ function registerTextIndentShortcut(textbus) {
2443
2444
 
2444
2445
  class ImageComponent extends core$1.Component {
2445
2446
  static fromJSON(textbus, json) {
2446
- return new ImageComponent(textbus, Object.assign({}, json));
2447
+ return new ImageComponent(Object.assign({}, json));
2447
2448
  }
2448
2449
  getSlots() {
2449
2450
  return [];
@@ -2483,9 +2484,9 @@ const imageComponentLoader = {
2483
2484
  match(element) {
2484
2485
  return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2485
2486
  },
2486
- read(element, textbus) {
2487
+ read(element) {
2487
2488
  const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2488
- return new ImageComponent(textbus, {
2489
+ return new ImageComponent({
2489
2490
  src: img.src,
2490
2491
  width: img.style.width || 'auto',
2491
2492
  height: img.style.height || 'auto'
@@ -2494,8 +2495,8 @@ const imageComponentLoader = {
2494
2495
  };
2495
2496
 
2496
2497
  class VideoComponent extends core$1.Component {
2497
- static fromJSON(textbus, json) {
2498
- return new VideoComponent(textbus, Object.assign({}, json));
2498
+ static fromJSON(_, json) {
2499
+ return new VideoComponent(Object.assign({}, json));
2499
2500
  }
2500
2501
  getSlots() {
2501
2502
  return [];
@@ -2535,9 +2536,9 @@ const videoComponentLoader = {
2535
2536
  match(element) {
2536
2537
  return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2537
2538
  },
2538
- read(element, textbus) {
2539
+ read(element) {
2539
2540
  const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2540
- return new VideoComponent(textbus, {
2541
+ return new VideoComponent({
2541
2542
  src: video.src,
2542
2543
  width: video.style.width || 'auto',
2543
2544
  height: video.style.height || 'auto'
@@ -2547,18 +2548,6 @@ const videoComponentLoader = {
2547
2548
 
2548
2549
  let ToolService = class ToolService {
2549
2550
  constructor(selection, controller) {
2550
- Object.defineProperty(this, "selection", {
2551
- enumerable: true,
2552
- configurable: true,
2553
- writable: true,
2554
- value: selection
2555
- });
2556
- Object.defineProperty(this, "controller", {
2557
- enumerable: true,
2558
- configurable: true,
2559
- writable: true,
2560
- value: controller
2561
- });
2562
2551
  Object.defineProperty(this, "state", {
2563
2552
  enumerable: true,
2564
2553
  configurable: true,
@@ -2571,12 +2560,11 @@ let ToolService = class ToolService {
2571
2560
  writable: true,
2572
2561
  value: void 0
2573
2562
  });
2574
- const [state, updateState] = hooks.useProduce({
2563
+ this.state = core.createSignal({
2575
2564
  inSourceCode: false,
2576
2565
  readonly: controller.readonly,
2577
2566
  selectEmbed: false,
2578
2567
  });
2579
- this.state = state;
2580
2568
  this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2581
2569
  const { startSlot, endSlot, startOffset, endOffset } = selection;
2582
2570
  let is = false;
@@ -2586,10 +2574,10 @@ let ToolService = class ToolService {
2586
2574
  is = true;
2587
2575
  }
2588
2576
  }
2589
- updateState(draft => {
2590
- draft.selectEmbed = is;
2591
- draft.readonly = controller.readonly;
2592
- draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
2577
+ this.state.set({
2578
+ selectEmbed: is,
2579
+ readonly: controller.readonly,
2580
+ inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
2593
2581
  });
2594
2582
  });
2595
2583
  }
@@ -2613,7 +2601,7 @@ function AttrTool(props) {
2613
2601
  const selection = core.inject(core$1.Selection);
2614
2602
  const query = core.inject(core$1.Query);
2615
2603
  const refreshService = core.inject(exports.RefreshService);
2616
- const [checkStates, setCheckStates] = hooks.useProduce({
2604
+ const checkStates = core.reactive({
2617
2605
  textAlign: 'left',
2618
2606
  textIndent: 0
2619
2607
  });
@@ -2621,23 +2609,21 @@ function AttrTool(props) {
2621
2609
  if (!props.slot && !selection.isSelected) {
2622
2610
  return;
2623
2611
  }
2624
- setCheckStates(draft => {
2625
- const range = props.slot ? {
2626
- startSlot: props.slot,
2627
- endSlot: props.slot,
2628
- startOffset: 0,
2629
- endOffset: props.slot.length
2630
- } : {
2631
- startSlot: selection.startSlot,
2632
- startOffset: selection.startOffset,
2633
- endSlot: selection.endSlot,
2634
- endOffset: selection.endOffset
2635
- };
2636
- const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
2637
- const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
2638
- draft.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
2639
- draft.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
2640
- });
2612
+ const range = props.slot ? {
2613
+ startSlot: props.slot,
2614
+ endSlot: props.slot,
2615
+ startOffset: 0,
2616
+ endOffset: props.slot.length
2617
+ } : {
2618
+ startSlot: selection.startSlot,
2619
+ startOffset: selection.startOffset,
2620
+ endSlot: selection.endSlot,
2621
+ endOffset: selection.endOffset
2622
+ };
2623
+ const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
2624
+ const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
2625
+ checkStates.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
2626
+ checkStates.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
2641
2627
  }
2642
2628
  updateCheckStates();
2643
2629
  const subscription = refreshService.onRefresh.subscribe(() => {
@@ -2686,20 +2672,19 @@ function AttrTool(props) {
2686
2672
  }
2687
2673
  const commonState = useCommonState();
2688
2674
  return scopedCss.withScopedCSS(scopedId$e, () => {
2689
- const states = checkStates();
2690
2675
  const b = commonState().inSourceCode || commonState().readonly;
2691
2676
  return (jsxRuntime.jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
2692
2677
  {
2693
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
2678
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: checkStates.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
2694
2679
  value: 't-l'
2695
2680
  }, {
2696
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
2681
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked: checkStates.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
2697
2682
  value: 't-r'
2698
2683
  }, {
2699
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
2684
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked: checkStates.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
2700
2685
  value: 't-c'
2701
2686
  }, {
2702
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
2687
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked: checkStates.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
2703
2688
  value: 't-j'
2704
2689
  }, {
2705
2690
  label: jsxRuntime.jsx(Divider, {}),
@@ -2711,7 +2696,7 @@ function AttrTool(props) {
2711
2696
  label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
2712
2697
  value: 'i-'
2713
2698
  }
2714
- ], children: props.children || jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
2699
+ ], children: props.children || jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${checkStates.textAlign || 'left'} icon` }) }) }));
2715
2700
  });
2716
2701
  }
2717
2702
 
@@ -2826,7 +2811,7 @@ const defaultColumnWidth = 100;
2826
2811
  class TableComponent extends core$1.Component {
2827
2812
  static fromJSON(textbus, json) {
2828
2813
  const registry = textbus.get(core$1.Registry);
2829
- return new TableComponent(textbus, {
2814
+ return new TableComponent({
2830
2815
  columnsConfig: json.columnsConfig || [],
2831
2816
  mergeConfig: json.mergeConfig || [],
2832
2817
  rows: json.rows.map(row => {
@@ -2842,14 +2827,14 @@ class TableComponent extends core$1.Component {
2842
2827
  })
2843
2828
  });
2844
2829
  }
2845
- constructor(textbus, state = {
2830
+ constructor(state = {
2846
2831
  columnsConfig: Array.from({ length: 5 }).fill(defaultColumnWidth),
2847
2832
  mergeConfig: {},
2848
2833
  rows: Array.from({ length: 3 }).map(() => {
2849
2834
  return {
2850
2835
  height: defaultRowHeight,
2851
2836
  cells: Array.from({ length: 5 }).map(() => {
2852
- const p = new ParagraphComponent(textbus);
2837
+ const p = new ParagraphComponent();
2853
2838
  const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
2854
2839
  slot.insert(p);
2855
2840
  return {
@@ -2860,18 +2845,18 @@ class TableComponent extends core$1.Component {
2860
2845
  };
2861
2846
  })
2862
2847
  }) {
2863
- super(textbus, state);
2848
+ super(state);
2864
2849
  Object.defineProperty(this, "selection", {
2865
2850
  enumerable: true,
2866
2851
  configurable: true,
2867
2852
  writable: true,
2868
- value: this.textbus.get(core$1.Selection)
2853
+ value: void 0
2869
2854
  });
2870
2855
  Object.defineProperty(this, "commander", {
2871
2856
  enumerable: true,
2872
2857
  configurable: true,
2873
2858
  writable: true,
2874
- value: this.textbus.get(core$1.Commander)
2859
+ value: void 0
2875
2860
  });
2876
2861
  Object.defineProperty(this, "focus", {
2877
2862
  enumerable: true,
@@ -3136,6 +3121,8 @@ class TableComponent extends core$1.Component {
3136
3121
  }
3137
3122
  setup() {
3138
3123
  const selection = core$1.useContext(core$1.Selection);
3124
+ this.selection = selection;
3125
+ this.commander = core$1.useContext(core$1.Commander);
3139
3126
  core$1.onFocusIn(() => {
3140
3127
  this.focus.next(true);
3141
3128
  });
@@ -3153,7 +3140,7 @@ class TableComponent extends core$1.Component {
3153
3140
  this.tableSelection.set(null);
3154
3141
  }
3155
3142
  });
3156
- core$1.onDestroy(() => {
3143
+ core$1.onDetach(() => {
3157
3144
  sub.unsubscribe();
3158
3145
  });
3159
3146
  core$1.onGetRanges(ev => {
@@ -3263,7 +3250,7 @@ class TableComponent extends core$1.Component {
3263
3250
  const slot = new core$1.Slot([
3264
3251
  core$1.ContentType.BlockComponent,
3265
3252
  ]);
3266
- slot.insert(new ParagraphComponent(this.textbus, {
3253
+ slot.insert(new ParagraphComponent({
3267
3254
  slot: new core$1.Slot([
3268
3255
  core$1.ContentType.InlineComponent,
3269
3256
  core$1.ContentType.Text
@@ -3288,7 +3275,7 @@ class TableComponent extends core$1.Component {
3288
3275
  const slot = new core$1.Slot([
3289
3276
  core$1.ContentType.BlockComponent,
3290
3277
  ]);
3291
- slot.insert(new ParagraphComponent(this.textbus, {
3278
+ slot.insert(new ParagraphComponent({
3292
3279
  slot: new core$1.Slot([
3293
3280
  core$1.ContentType.InlineComponent,
3294
3281
  core$1.ContentType.Text
@@ -3369,7 +3356,7 @@ const strikeThroughFormatLoader = {
3369
3356
  class TodolistComponent extends core$1.Component {
3370
3357
  static fromJSON(textbus, json) {
3371
3358
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
3372
- return new TodolistComponent(textbus, {
3359
+ return new TodolistComponent({
3373
3360
  slot,
3374
3361
  checked: json.checked
3375
3362
  });
@@ -3378,7 +3365,6 @@ class TodolistComponent extends core$1.Component {
3378
3365
  return [this.state.slot];
3379
3366
  }
3380
3367
  setup() {
3381
- const textbus = core$1.useContext();
3382
3368
  const commander = core$1.useContext(core$1.Commander);
3383
3369
  const selection = core$1.useContext(core$1.Selection);
3384
3370
  core$1.onBreak(ev => {
@@ -3388,7 +3374,7 @@ class TodolistComponent extends core$1.Component {
3388
3374
  const beforeIndex = this.parent.indexOf(this);
3389
3375
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3390
3376
  if (beforeComponent instanceof TodolistComponent) {
3391
- const nextComponent = new ParagraphComponent(textbus, {
3377
+ const nextComponent = new ParagraphComponent({
3392
3378
  slot: new core$1.Slot([
3393
3379
  core$1.ContentType.Text,
3394
3380
  core$1.ContentType.InlineComponent
@@ -3402,7 +3388,7 @@ class TodolistComponent extends core$1.Component {
3402
3388
  return;
3403
3389
  }
3404
3390
  }
3405
- const nextParagraph = new TodolistComponent(textbus, {
3391
+ const nextParagraph = new TodolistComponent({
3406
3392
  checked: this.state.checked,
3407
3393
  slot
3408
3394
  });
@@ -3419,7 +3405,7 @@ class TodolistComponent extends core$1.Component {
3419
3405
  return false;
3420
3406
  }
3421
3407
  const slot = selection.commonAncestorSlot.cut();
3422
- const paragraph = new ParagraphComponent(textbus, {
3408
+ const paragraph = new ParagraphComponent({
3423
3409
  slot
3424
3410
  });
3425
3411
  commander.replaceComponent(this, paragraph);
@@ -3507,12 +3493,12 @@ const todolistComponentLoader = {
3507
3493
  match(element) {
3508
3494
  return element.dataset.component === TodolistComponent.componentName;
3509
3495
  },
3510
- read(element, injector, slotParser) {
3496
+ read(element, _, slotParser) {
3511
3497
  const slot = slotParser(new core$1.Slot([
3512
3498
  core$1.ContentType.Text,
3513
3499
  core$1.ContentType.InlineComponent
3514
3500
  ]), element.children[1]);
3515
- return new TodolistComponent(injector, {
3501
+ return new TodolistComponent({
3516
3502
  checked: element.children[0].hasAttribute('checked'),
3517
3503
  slot
3518
3504
  });
@@ -3531,7 +3517,7 @@ function toList(textbus, type) {
3531
3517
  },
3532
3518
  stateFactory(slots) {
3533
3519
  return slots.map((slot, index) => {
3534
- return new ListComponent(textbus, {
3520
+ return new ListComponent({
3535
3521
  type,
3536
3522
  reorder: index === 0,
3537
3523
  slot
@@ -3555,7 +3541,7 @@ function registerListShortcut(textbus) {
3555
3541
  }
3556
3542
  class ListComponent extends core$1.Component {
3557
3543
  static fromJSON(textbus, json) {
3558
- return new ListComponent(textbus, {
3544
+ return new ListComponent({
3559
3545
  type: json.type,
3560
3546
  reorder: json.reorder,
3561
3547
  slot: textbus.get(core$1.Registry).createSlot(json.slot)
@@ -3565,7 +3551,6 @@ class ListComponent extends core$1.Component {
3565
3551
  return [this.state.slot];
3566
3552
  }
3567
3553
  setup() {
3568
- const textbus = core$1.useContext();
3569
3554
  const commander = core$1.useContext(core$1.Commander);
3570
3555
  const selection = core$1.useContext(core$1.Selection);
3571
3556
  const updateAfterList = (ref) => {
@@ -3595,7 +3580,7 @@ class ListComponent extends core$1.Component {
3595
3580
  const beforeIndex = this.parent.indexOf(this);
3596
3581
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
3597
3582
  if (beforeComponent instanceof ListComponent) {
3598
- const nextComponent = new ParagraphComponent(textbus, {
3583
+ const nextComponent = new ParagraphComponent({
3599
3584
  slot: new core$1.Slot([
3600
3585
  core$1.ContentType.Text,
3601
3586
  core$1.ContentType.InlineComponent
@@ -3610,7 +3595,7 @@ class ListComponent extends core$1.Component {
3610
3595
  return;
3611
3596
  }
3612
3597
  }
3613
- const nextList = new ListComponent(textbus, {
3598
+ const nextList = new ListComponent({
3614
3599
  slot,
3615
3600
  reorder: false,
3616
3601
  type: this.state.type
@@ -3629,7 +3614,7 @@ class ListComponent extends core$1.Component {
3629
3614
  return false;
3630
3615
  }
3631
3616
  const slot = selection.commonAncestorSlot.cut();
3632
- const paragraph = new ParagraphComponent(textbus, {
3617
+ const paragraph = new ParagraphComponent({
3633
3618
  slot
3634
3619
  });
3635
3620
  commander.replaceComponent(this, paragraph);
@@ -3805,7 +3790,7 @@ const listComponentLoader = {
3805
3790
  core$1.ContentType.InlineComponent,
3806
3791
  core$1.ContentType.Text
3807
3792
  ]), element.querySelector('.xnote-list-content') || document.createElement('div'));
3808
- return new ListComponent(textbus, {
3793
+ return new ListComponent({
3809
3794
  slot,
3810
3795
  reorder: element.dataset.reorder !== 'false',
3811
3796
  type
@@ -3819,7 +3804,7 @@ const listComponentLoader = {
3819
3804
  core$1.ContentType.InlineComponent,
3820
3805
  core$1.ContentType.Text
3821
3806
  ]), i);
3822
- const component = new ListComponent(textbus, {
3807
+ const component = new ListComponent({
3823
3808
  slot,
3824
3809
  reorder: index === 0,
3825
3810
  type
@@ -3834,7 +3819,7 @@ function useActiveBlock() {
3834
3819
  const query = core.inject(core$1.Query);
3835
3820
  const selection = core.inject(core$1.Selection);
3836
3821
  const refreshService = core.inject(exports.RefreshService);
3837
- const [checkStates, setCheckStates] = hooks.useProduce({
3822
+ const checkStates = core.reactive({
3838
3823
  paragraph: false,
3839
3824
  h1: false,
3840
3825
  h2: false,
@@ -3851,22 +3836,20 @@ function useActiveBlock() {
3851
3836
  highlightBox: false
3852
3837
  });
3853
3838
  function updateCheckStates(range) {
3854
- setCheckStates(draft => {
3855
- const heading = query.queryAttributeByRange(headingAttr, range);
3856
- draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
3857
- draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
3858
- if (heading.state === core$1.QueryStateType.Enabled) {
3859
- draft[heading.value] = true;
3860
- draft.paragraph = false;
3861
- }
3862
- const queryList = query.queryComponentByRange(ListComponent, range);
3863
- draft.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
3864
- draft.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
3865
- draft.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
3866
- draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
3867
- draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
3868
- draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
3869
- });
3839
+ const heading = query.queryAttributeByRange(headingAttr, range);
3840
+ checkStates.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
3841
+ checkStates.h1 = checkStates.h2 = checkStates.h3 = checkStates.h4 = checkStates.h5 = checkStates.h6 = false;
3842
+ if (heading.state === core$1.QueryStateType.Enabled) {
3843
+ checkStates[heading.value] = true;
3844
+ checkStates.paragraph = false;
3845
+ }
3846
+ const queryList = query.queryComponentByRange(ListComponent, range);
3847
+ checkStates.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
3848
+ checkStates.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
3849
+ checkStates.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
3850
+ checkStates.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
3851
+ checkStates.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
3852
+ checkStates.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
3870
3853
  }
3871
3854
  const subscription = refreshService.onRefresh.subscribe(() => {
3872
3855
  if (!selection.isSelected) {
@@ -3899,7 +3882,7 @@ function useActiveBlock() {
3899
3882
  endOffset: selection.endOffset
3900
3883
  });
3901
3884
  }
3902
- return checkStates();
3885
+ return checkStates;
3903
3886
  };
3904
3887
  }
3905
3888
 
@@ -3930,7 +3913,7 @@ function useBlockTransform() {
3930
3913
  ]);
3931
3914
  },
3932
3915
  stateFactory(slots) {
3933
- return slots.map(slot => new ParagraphComponent(textbus, {
3916
+ return slots.map(slot => new ParagraphComponent({
3934
3917
  slot
3935
3918
  }));
3936
3919
  }
@@ -3938,7 +3921,7 @@ function useBlockTransform() {
3938
3921
  break;
3939
3922
  case 'table':
3940
3923
  {
3941
- const table = new TableComponent(textbus);
3924
+ const table = new TableComponent();
3942
3925
  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) {
3943
3926
  commander.replaceComponent(selection.commonAncestorComponent, table);
3944
3927
  }
@@ -3959,7 +3942,7 @@ function useBlockTransform() {
3959
3942
  },
3960
3943
  stateFactory(slots) {
3961
3944
  return slots.map(slot => {
3962
- return new TodolistComponent(textbus, {
3945
+ return new TodolistComponent({
3963
3946
  checked: false,
3964
3947
  slot
3965
3948
  });
@@ -3988,7 +3971,7 @@ function useBlockTransform() {
3988
3971
  },
3989
3972
  stateFactory(slots) {
3990
3973
  return slots.map(slot => {
3991
- return new ParagraphComponent(textbus, {
3974
+ return new ParagraphComponent({
3992
3975
  slot
3993
3976
  });
3994
3977
  });
@@ -4004,7 +3987,7 @@ function useBlockTransform() {
4004
3987
  ]);
4005
3988
  },
4006
3989
  stateFactory(slots) {
4007
- return [new SourceCodeComponent(textbus, {
3990
+ return [new SourceCodeComponent({
4008
3991
  lang: '',
4009
3992
  lineNumber: true,
4010
3993
  autoBreak: true,
@@ -4036,7 +4019,7 @@ function useBlockTransform() {
4036
4019
  });
4037
4020
  }
4038
4021
  else {
4039
- const block = new HighlightBoxComponent(textbus);
4022
+ const block = new HighlightBoxComponent();
4040
4023
  const slot = block.state.slot;
4041
4024
  if (selection.startSlot === selection.endSlot) {
4042
4025
  const parentComponent = selection.startSlot.parent;
@@ -4418,7 +4401,7 @@ function BoldTool() {
4418
4401
  const textbus = core.inject(core$1.Textbus);
4419
4402
  const refreshService = core.inject(exports.RefreshService);
4420
4403
  const commonState = useCommonState();
4421
- const [viewModel, update] = hooks.useProduce({
4404
+ const viewModel = core.reactive({
4422
4405
  highlight: false,
4423
4406
  });
4424
4407
  function toggle() {
@@ -4426,16 +4409,13 @@ function BoldTool() {
4426
4409
  }
4427
4410
  const sub = refreshService.onRefresh.subscribe(() => {
4428
4411
  const state = query.queryFormat(boldFormatter);
4429
- update(draft => {
4430
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
4431
- });
4412
+ viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
4432
4413
  });
4433
4414
  core.onUnmounted(() => {
4434
4415
  sub.unsubscribe();
4435
4416
  });
4436
4417
  return () => {
4437
- const vm = viewModel();
4438
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-bold" }) });
4418
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-bold" }) });
4439
4419
  };
4440
4420
  }
4441
4421
 
@@ -4457,7 +4437,7 @@ function CodeTool() {
4457
4437
  const refreshService = core.inject(exports.RefreshService);
4458
4438
  const textbus = core.inject(core$1.Textbus);
4459
4439
  const commonState = useCommonState();
4460
- const [viewModel, update] = hooks.useProduce({
4440
+ const viewModel = core.reactive({
4461
4441
  highlight: false,
4462
4442
  });
4463
4443
  function toggle() {
@@ -4465,16 +4445,13 @@ function CodeTool() {
4465
4445
  }
4466
4446
  const sub = refreshService.onRefresh.subscribe(() => {
4467
4447
  const state = query.queryFormat(codeFormatter);
4468
- update(draft => {
4469
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
4470
- });
4448
+ viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
4471
4449
  });
4472
4450
  core.onUnmounted(() => {
4473
4451
  sub.unsubscribe();
4474
4452
  });
4475
4453
  return () => {
4476
- const vm = viewModel();
4477
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-code" }) });
4454
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-code" }) });
4478
4455
  };
4479
4456
  }
4480
4457
 
@@ -4693,7 +4670,7 @@ class KatexEditor extends core$1.Textbus {
4693
4670
  }
4694
4671
  mount(host, code) {
4695
4672
  this.host = host;
4696
- const model = new SourceCodeComponent(this, {
4673
+ const model = new SourceCodeComponent({
4697
4674
  lineNumber: true,
4698
4675
  autoBreak: true,
4699
4676
  lang: 'latex',
@@ -4722,15 +4699,15 @@ class KatexEditor extends core$1.Textbus {
4722
4699
 
4723
4700
  class KatexComponent extends core$1.Component {
4724
4701
  static fromJSON(textbus, state) {
4725
- return new KatexComponent(textbus, state);
4702
+ return new KatexComponent(state);
4726
4703
  }
4727
- constructor(textbus, state = {
4704
+ constructor(state = {
4728
4705
  text: '% \\f is defined as #1f(#2) using the macro\n' +
4729
4706
  '\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
4730
4707
  '\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
4731
4708
  '\\,d\\xi'
4732
4709
  }) {
4733
- super(textbus, state);
4710
+ super(state);
4734
4711
  }
4735
4712
  getSlots() {
4736
4713
  return [];
@@ -4818,9 +4795,9 @@ const katexComponentLoader = {
4818
4795
  match(element) {
4819
4796
  return element.dataset.component === KatexComponent.componentName;
4820
4797
  },
4821
- read(element, textbus) {
4798
+ read(element) {
4822
4799
  const value = element.dataset.katex || '';
4823
- return new KatexComponent(textbus, {
4800
+ return new KatexComponent({
4824
4801
  text: decodeURIComponent(value)
4825
4802
  });
4826
4803
  }
@@ -4864,7 +4841,7 @@ function InsertMenu(props) {
4864
4841
  if (/h[1-6]/.test(type)) {
4865
4842
  slot.setAttribute(headingAttr, type);
4866
4843
  }
4867
- const p = new ParagraphComponent(textbus, {
4844
+ const p = new ParagraphComponent({
4868
4845
  slot
4869
4846
  });
4870
4847
  insertComponent(p);
@@ -4878,7 +4855,7 @@ function InsertMenu(props) {
4878
4855
  core$1.ContentType.InlineComponent,
4879
4856
  core$1.ContentType.Text
4880
4857
  ]);
4881
- const list = new ListComponent(textbus, {
4858
+ const list = new ListComponent({
4882
4859
  slot,
4883
4860
  reorder: true,
4884
4861
  type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
@@ -4892,7 +4869,7 @@ function InsertMenu(props) {
4892
4869
  const slot = new core$1.Slot([
4893
4870
  core$1.ContentType.Text
4894
4871
  ]);
4895
- const comp = new SourceCodeComponent(textbus, {
4872
+ const comp = new SourceCodeComponent({
4896
4873
  lang: '',
4897
4874
  lineNumber: true,
4898
4875
  slots: [{
@@ -4906,7 +4883,7 @@ function InsertMenu(props) {
4906
4883
  break;
4907
4884
  case 'table':
4908
4885
  {
4909
- const table = new TableComponent(textbus);
4886
+ const table = new TableComponent();
4910
4887
  insertComponent(table);
4911
4888
  textbus.nextTick(() => {
4912
4889
  selection.selectFirstPosition(table, true, true);
@@ -4919,7 +4896,7 @@ function InsertMenu(props) {
4919
4896
  core$1.ContentType.Text,
4920
4897
  core$1.ContentType.InlineComponent
4921
4898
  ]);
4922
- const comp = new TodolistComponent(textbus, {
4899
+ const comp = new TodolistComponent({
4923
4900
  slot,
4924
4901
  checked: false
4925
4902
  });
@@ -4930,7 +4907,7 @@ function InsertMenu(props) {
4930
4907
  case 'image':
4931
4908
  if (fileUploader) {
4932
4909
  Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
4933
- const img = new ImageComponent(textbus, {
4910
+ const img = new ImageComponent({
4934
4911
  src: url
4935
4912
  });
4936
4913
  commander.insert(img);
@@ -4940,7 +4917,7 @@ function InsertMenu(props) {
4940
4917
  case 'video':
4941
4918
  if (fileUploader) {
4942
4919
  Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
4943
- const img = new VideoComponent(textbus, {
4920
+ const img = new VideoComponent({
4944
4921
  src: url
4945
4922
  });
4946
4923
  commander.insert(img);
@@ -4949,8 +4926,8 @@ function InsertMenu(props) {
4949
4926
  break;
4950
4927
  case 'highlightBox':
4951
4928
  {
4952
- const p = new ParagraphComponent(textbus);
4953
- const comp = new HighlightBoxComponent(textbus);
4929
+ const p = new ParagraphComponent();
4930
+ const comp = new HighlightBoxComponent();
4954
4931
  comp.state.slot.insert(p);
4955
4932
  insertComponent(comp);
4956
4933
  selection.setPosition(p.state.slot, 0);
@@ -4958,8 +4935,8 @@ function InsertMenu(props) {
4958
4935
  break;
4959
4936
  case 'katex':
4960
4937
  {
4961
- const p = new ParagraphComponent(textbus);
4962
- const comp = new KatexComponent(textbus);
4938
+ const p = new ParagraphComponent();
4939
+ const comp = new KatexComponent();
4963
4940
  p.state.slot.insert(comp);
4964
4941
  insertComponent(p);
4965
4942
  selection.selectComponent(comp);
@@ -4967,17 +4944,17 @@ function InsertMenu(props) {
4967
4944
  break;
4968
4945
  case 'step':
4969
4946
  {
4970
- const step = new StepComponent(textbus, {
4947
+ const step = new StepComponent({
4971
4948
  step: 0,
4972
- items: [createStepItem(textbus)]
4949
+ items: [createStepItem()]
4973
4950
  });
4974
4951
  insertComponent(step);
4975
4952
  selection.selectFirstPosition(step, false, true);
4976
4953
  }
4977
4954
  break;
4978
4955
  case 'timeline': {
4979
- const timeline = new TimelineComponent(textbus, {
4980
- items: [createTimelineItem(textbus, '#296eff')]
4956
+ const timeline = new TimelineComponent({
4957
+ items: [createTimelineItem('#296eff')]
4981
4958
  });
4982
4959
  insertComponent(timeline);
4983
4960
  selection.selectFirstPosition(timeline, false, true);
@@ -5010,7 +4987,7 @@ function ItalicTool() {
5010
4987
  const query = core.inject(core$1.Query);
5011
4988
  const refreshService = core.inject(exports.RefreshService);
5012
4989
  const textbus = core.inject(core$1.Textbus);
5013
- const [viewModel, update] = hooks.useProduce({
4990
+ const viewModel = core.reactive({
5014
4991
  highlight: false,
5015
4992
  });
5016
4993
  function toggle() {
@@ -5018,17 +4995,14 @@ function ItalicTool() {
5018
4995
  }
5019
4996
  const sub = refreshService.onRefresh.subscribe(() => {
5020
4997
  const state = query.queryFormat(italicFormatter);
5021
- update(draft => {
5022
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
5023
- });
4998
+ viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
5024
4999
  });
5025
5000
  core.onUnmounted(() => {
5026
5001
  sub.unsubscribe();
5027
5002
  });
5028
5003
  const commonState = useCommonState();
5029
5004
  return () => {
5030
- const vm = viewModel();
5031
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
5005
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
5032
5006
  };
5033
5007
  }
5034
5008
 
@@ -5137,7 +5111,7 @@ function StrikeThroughTool() {
5137
5111
  const query = core.inject(core$1.Query);
5138
5112
  const refreshService = core.inject(exports.RefreshService);
5139
5113
  const textbus = core.inject(core$1.Textbus);
5140
- const [viewModel, update] = hooks.useProduce({
5114
+ const viewModel = core.reactive({
5141
5115
  highlight: false,
5142
5116
  });
5143
5117
  function toggle() {
@@ -5145,17 +5119,14 @@ function StrikeThroughTool() {
5145
5119
  }
5146
5120
  const sub = refreshService.onRefresh.subscribe(() => {
5147
5121
  const state = query.queryFormat(strikeThroughFormatter);
5148
- update(draft => {
5149
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
5150
- });
5122
+ viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
5151
5123
  });
5152
5124
  core.onUnmounted(() => {
5153
5125
  sub.unsubscribe();
5154
5126
  });
5155
5127
  const commonState = useCommonState();
5156
5128
  return () => {
5157
- const vm = viewModel();
5158
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
5129
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
5159
5130
  };
5160
5131
  }
5161
5132
 
@@ -5163,13 +5134,11 @@ function SubscriptTool() {
5163
5134
  const query = core.inject(core$1.Query);
5164
5135
  const selection = core.inject(core$1.Selection);
5165
5136
  const commander = core.inject(core$1.Commander);
5166
- const [state, updateState] = hooks.useProduce({
5137
+ const state = core.reactive({
5167
5138
  highlight: false
5168
5139
  });
5169
5140
  const sub = selection.onChange.subscribe(() => {
5170
- updateState(draft => {
5171
- draft.highlight = getState();
5172
- });
5141
+ state.highlight = getState();
5173
5142
  });
5174
5143
  function getState() {
5175
5144
  const s = query.queryFormat(subscriptFormatter);
@@ -5190,7 +5159,7 @@ function SubscriptTool() {
5190
5159
  }
5191
5160
  const commonState = useCommonState();
5192
5161
  return () => {
5193
- return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state().highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-subscript" }) }));
5162
+ return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-subscript" }) }));
5194
5163
  };
5195
5164
  }
5196
5165
 
@@ -5198,13 +5167,11 @@ function SuperscriptTool() {
5198
5167
  const query = core.inject(core$1.Query);
5199
5168
  const selection = core.inject(core$1.Selection);
5200
5169
  const commander = core.inject(core$1.Commander);
5201
- const [state, updateState] = hooks.useProduce({
5170
+ const state = core.reactive({
5202
5171
  highlight: false
5203
5172
  });
5204
5173
  const sub = selection.onChange.subscribe(() => {
5205
- updateState(draft => {
5206
- draft.highlight = getState();
5207
- });
5174
+ state.highlight = getState();
5208
5175
  });
5209
5176
  function getState() {
5210
5177
  const s = query.queryFormat(superscriptFormatter);
@@ -5225,7 +5192,7 @@ function SuperscriptTool() {
5225
5192
  }
5226
5193
  const commonState = useCommonState();
5227
5194
  return () => {
5228
- return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state().highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-superscript" }) }));
5195
+ return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-superscript" }) }));
5229
5196
  };
5230
5197
  }
5231
5198
 
@@ -5327,7 +5294,7 @@ function UnderlineTool() {
5327
5294
  const query = core.inject(core$1.Query);
5328
5295
  const refreshService = core.inject(exports.RefreshService);
5329
5296
  const textbus = core.inject(core$1.Textbus);
5330
- const [viewModel, update] = hooks.useProduce({
5297
+ const viewModel = core.reactive({
5331
5298
  highlight: false,
5332
5299
  });
5333
5300
  function toggle() {
@@ -5335,17 +5302,14 @@ function UnderlineTool() {
5335
5302
  }
5336
5303
  const sub = refreshService.onRefresh.subscribe(() => {
5337
5304
  const state = query.queryFormat(underlineFormatter);
5338
- update(draft => {
5339
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
5340
- });
5305
+ viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
5341
5306
  });
5342
5307
  core.onUnmounted(() => {
5343
5308
  sub.unsubscribe();
5344
5309
  });
5345
5310
  const commonState = useCommonState();
5346
5311
  return () => {
5347
- const vm = viewModel();
5348
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
5312
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
5349
5313
  };
5350
5314
  }
5351
5315
 
@@ -5537,7 +5501,7 @@ const cellBackgroundAttrLoader = {
5537
5501
  function CellBackgroundTool() {
5538
5502
  const refreshService = core.inject(exports.RefreshService);
5539
5503
  const selection = core.inject(core$1.Selection);
5540
- const [viewModel, update] = hooks.useProduce({
5504
+ const viewModel = core.reactive({
5541
5505
  disabled: false,
5542
5506
  });
5543
5507
  function setColor(picker) {
@@ -5578,9 +5542,7 @@ function CellBackgroundTool() {
5578
5542
  }
5579
5543
  }
5580
5544
  const sub = refreshService.onRefresh.subscribe(() => {
5581
- update(draft => {
5582
- draft.disabled = !isInTable(selection);
5583
- });
5545
+ viewModel.disabled = !isInTable(selection);
5584
5546
  });
5585
5547
  core.onUnmounted(() => {
5586
5548
  sub.unsubscribe();
@@ -5596,8 +5558,7 @@ function CellBackgroundTool() {
5596
5558
  '#c596e0',
5597
5559
  ];
5598
5560
  return () => {
5599
- const vm = viewModel();
5600
- const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
5561
+ const d = viewModel.disabled || commonState().readonly || commonState().inSourceCode;
5601
5562
  return (jsxRuntime.jsx(Dropdown, { width: '177px', disabled: d, menu: jsxRuntime.jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { disabled: d, arrow: true, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
5602
5563
  };
5603
5564
  }
@@ -5605,7 +5566,7 @@ function CellBackgroundTool() {
5605
5566
  function MergeCellsTool() {
5606
5567
  const refreshService = core.inject(exports.RefreshService);
5607
5568
  const selection = core.inject(core$1.Selection);
5608
- const [viewModel, update] = hooks.useProduce({
5569
+ const viewModel = core.reactive({
5609
5570
  highlight: false,
5610
5571
  disabled: false,
5611
5572
  });
@@ -5616,33 +5577,30 @@ function MergeCellsTool() {
5616
5577
  }
5617
5578
  }
5618
5579
  const sub = refreshService.onRefresh.subscribe(() => {
5619
- update(draft => {
5620
- const is = isInTable(selection);
5621
- if (is) {
5622
- const p1 = getTableSlotBySlot(selection.startSlot);
5623
- const p2 = getTableSlotBySlot(selection.endSlot);
5624
- if (p1 && p2) {
5625
- draft.disabled = p1 === p2;
5626
- return;
5627
- }
5580
+ const is = isInTable(selection);
5581
+ if (is) {
5582
+ const p1 = getTableSlotBySlot(selection.startSlot);
5583
+ const p2 = getTableSlotBySlot(selection.endSlot);
5584
+ if (p1 && p2) {
5585
+ viewModel.disabled = p1 === p2;
5586
+ return;
5628
5587
  }
5629
- draft.disabled = true;
5630
- });
5588
+ }
5589
+ viewModel.disabled = true;
5631
5590
  });
5632
5591
  core.onUnmounted(() => {
5633
5592
  sub.unsubscribe();
5634
5593
  });
5635
5594
  const commonState = useCommonState();
5636
5595
  return () => {
5637
- const vm = viewModel();
5638
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
5596
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
5639
5597
  };
5640
5598
  }
5641
5599
 
5642
5600
  function SplitCellsTool() {
5643
5601
  const refreshService = core.inject(exports.RefreshService);
5644
5602
  const selection = core.inject(core$1.Selection);
5645
- const [viewModel, update] = hooks.useProduce({
5603
+ const viewModel = core.reactive({
5646
5604
  highlight: false,
5647
5605
  disabled: false,
5648
5606
  });
@@ -5667,47 +5625,44 @@ function SplitCellsTool() {
5667
5625
  }
5668
5626
  const sub = refreshService.onRefresh.subscribe(() => {
5669
5627
  const commonAncestorComponent = selection.commonAncestorComponent;
5670
- update(draft => {
5671
- if (commonAncestorComponent instanceof TableComponent) {
5672
- const slots = commonAncestorComponent.getSelectedNormalizedSlots();
5673
- if (slots) {
5674
- for (const item of slots) {
5675
- for (const cell of item.cells) {
5676
- if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
5677
- draft.disabled = false;
5678
- return;
5679
- }
5628
+ if (commonAncestorComponent instanceof TableComponent) {
5629
+ const slots = commonAncestorComponent.getSelectedNormalizedSlots();
5630
+ if (slots) {
5631
+ for (const item of slots) {
5632
+ for (const cell of item.cells) {
5633
+ if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
5634
+ viewModel.disabled = false;
5635
+ return;
5680
5636
  }
5681
5637
  }
5682
5638
  }
5683
5639
  }
5684
- else {
5685
- let parentSlot = selection.commonAncestorSlot;
5686
- while (parentSlot) {
5687
- if (parentSlot.parent instanceof TableComponent) {
5688
- const slots = parentSlot.parent.getNormalizedData();
5689
- for (const item of slots) {
5690
- for (const cell of item.cells) {
5691
- if (cell.raw.slot === parentSlot) {
5692
- draft.disabled = !(cell.colspan > 1 || cell.colspan > 1);
5693
- return;
5694
- }
5640
+ }
5641
+ else {
5642
+ let parentSlot = selection.commonAncestorSlot;
5643
+ while (parentSlot) {
5644
+ if (parentSlot.parent instanceof TableComponent) {
5645
+ const slots = parentSlot.parent.getNormalizedData();
5646
+ for (const item of slots) {
5647
+ for (const cell of item.cells) {
5648
+ if (cell.raw.slot === parentSlot) {
5649
+ viewModel.disabled = !(cell.colspan > 1 || cell.colspan > 1);
5650
+ return;
5695
5651
  }
5696
5652
  }
5697
5653
  }
5698
- parentSlot = parentSlot.parentSlot;
5699
5654
  }
5655
+ parentSlot = parentSlot.parentSlot;
5700
5656
  }
5701
- draft.disabled = true;
5702
- });
5657
+ }
5658
+ viewModel.disabled = true;
5703
5659
  });
5704
5660
  core.onUnmounted(() => {
5705
5661
  sub.unsubscribe();
5706
5662
  });
5707
5663
  const commonState = useCommonState();
5708
5664
  return () => {
5709
- const vm = viewModel();
5710
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
5665
+ return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
5711
5666
  };
5712
5667
  }
5713
5668
 
@@ -5743,15 +5698,13 @@ const LeftToolbar = core.withAnnotation({
5743
5698
  refreshService.onRefresh.next();
5744
5699
  }
5745
5700
  }
5746
- const [positionSignal, updatePosition] = hooks.useProduce({
5701
+ const positionSignal = core.reactive({
5747
5702
  left: 0,
5748
5703
  top: 0,
5749
5704
  display: false
5750
5705
  });
5751
5706
  const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
5752
- updatePosition(d => {
5753
- d.display = editorService.canShowLeftToolbar;
5754
- });
5707
+ positionSignal.display = editorService.canShowLeftToolbar;
5755
5708
  });
5756
5709
  core.onUnmounted(() => {
5757
5710
  sub.unsubscribe();
@@ -5789,18 +5742,14 @@ const LeftToolbar = core.withAnnotation({
5789
5742
  slot.parent instanceof SourceCodeComponent ||
5790
5743
  slot.parent instanceof TableComponent);
5791
5744
  const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
5792
- updatePosition(draft => {
5793
- const containerRect = docContentContainer.getBoundingClientRect();
5794
- const currentRect = nativeNode.getBoundingClientRect();
5795
- draft.display = true;
5796
- draft.left = currentRect.left - containerRect.left;
5797
- draft.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
5798
- });
5745
+ const containerRect = docContentContainer.getBoundingClientRect();
5746
+ const currentRect = nativeNode.getBoundingClientRect();
5747
+ positionSignal.display = true;
5748
+ positionSignal.left = currentRect.left - containerRect.left;
5749
+ positionSignal.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
5799
5750
  }
5800
5751
  else {
5801
- updatePosition(draft => {
5802
- draft.display = false;
5803
- });
5752
+ positionSignal.display = false;
5804
5753
  isEmptyBlock.set(false);
5805
5754
  }
5806
5755
  });
@@ -5879,7 +5828,6 @@ const LeftToolbar = core.withAnnotation({
5879
5828
  }
5880
5829
  return scopedCss.withScopedCSS(scopedId$a, () => {
5881
5830
  var _a;
5882
- const position = positionSignal();
5883
5831
  const slot = activeSlot();
5884
5832
  let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
5885
5833
  const states = checkStates(slot);
@@ -5909,9 +5857,9 @@ const LeftToolbar = core.withAnnotation({
5909
5857
  const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
5910
5858
  const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
5911
5859
  return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
5912
- left: position.left + 'px',
5913
- top: position.top + 'px',
5914
- display: position.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5860
+ left: positionSignal.left + 'px',
5861
+ top: positionSignal.top + 'px',
5862
+ display: positionSignal.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5915
5863
  }, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
5916
5864
  position: 'absolute',
5917
5865
  right: 0,
@@ -6039,14 +5987,14 @@ const InlineToolbar = core.withAnnotation({
6039
5987
  const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20), core$1.tap(() => {
6040
5988
  refreshService.onRefresh.next();
6041
5989
  }), core$1.delay(200)).subscribe(() => {
6042
- if (viewPosition().isHide) {
5990
+ if (viewPosition.isHide) {
6043
5991
  editorService.changeLeftToolbarVisible(true);
6044
5992
  }
6045
5993
  });
6046
5994
  core.onUnmounted(() => {
6047
5995
  subscription.unsubscribe();
6048
5996
  });
6049
- const [viewPosition, updateViewPosition] = hooks.useProduce({
5997
+ const viewPosition = core.reactive({
6050
5998
  left: 0,
6051
5999
  top: 0,
6052
6000
  isHide: true,
@@ -6124,21 +6072,17 @@ const InlineToolbar = core.withAnnotation({
6124
6072
  const top = toBottom ?
6125
6073
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
6126
6074
  selectionFocusRect.top - docRect.top - toolbarHeight - 10;
6127
- updateViewPosition(draft => {
6128
- draft.transitionDuration = .15;
6129
- draft.left = centerLeft - docRect.left;
6130
- // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
6131
- draft.top = top + 10;
6132
- });
6075
+ viewPosition.transitionDuration = .15;
6076
+ viewPosition.left = centerLeft - docRect.left;
6077
+ // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
6078
+ viewPosition.top = top + 10;
6133
6079
  return top;
6134
6080
  }
6135
6081
  const sub = textbus.onChange.pipe(core$1.debounceTime(100)).subscribe(() => {
6136
- if (!viewPosition().isHide) {
6082
+ if (!viewPosition.isHide) {
6137
6083
  const top = getTop();
6138
6084
  if (top !== null && !selection.isCollapsed) {
6139
- updateViewPosition(draft => {
6140
- draft.top = top;
6141
- });
6085
+ viewPosition.top = top;
6142
6086
  return;
6143
6087
  }
6144
6088
  }
@@ -6161,11 +6105,9 @@ const InlineToolbar = core.withAnnotation({
6161
6105
  return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
6162
6106
  }), core$1.map(getTop), core$1.delay(200)).subscribe((top) => {
6163
6107
  if (top !== null) {
6164
- updateViewPosition(draft => {
6165
- draft.isHide = false;
6166
- draft.opacity = 1;
6167
- draft.top = top;
6168
- });
6108
+ viewPosition.isHide = false;
6109
+ viewPosition.opacity = 1;
6110
+ viewPosition.top = top;
6169
6111
  editorService.changeLeftToolbarVisible(false);
6170
6112
  }
6171
6113
  else {
@@ -6178,11 +6120,9 @@ const InlineToolbar = core.withAnnotation({
6178
6120
  return;
6179
6121
  }
6180
6122
  mouseupSubscription.unsubscribe();
6181
- updateViewPosition(draft => {
6182
- draft.opacity = 0;
6183
- draft.isHide = true;
6184
- draft.transitionDuration = 0;
6185
- });
6123
+ viewPosition.opacity = 0;
6124
+ viewPosition.isHide = true;
6125
+ viewPosition.transitionDuration = 0;
6186
6126
  bindMouseup();
6187
6127
  });
6188
6128
  const instance = core.getCurrentInstance();
@@ -6195,14 +6135,13 @@ const InlineToolbar = core.withAnnotation({
6195
6135
  mouseupSubscription.unsubscribe();
6196
6136
  });
6197
6137
  return scopedCss.withScopedCSS(scopedId$8, () => {
6198
- const p = viewPosition();
6199
6138
  return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
6200
- left: p.left + 'px',
6201
- top: p.top + 'px',
6202
- pointerEvents: p.isHide ? 'none' : 'initial',
6203
- opacity: p.opacity,
6139
+ left: viewPosition.left + 'px',
6140
+ top: viewPosition.top + 'px',
6141
+ pointerEvents: viewPosition.isHide ? 'none' : 'initial',
6142
+ opacity: viewPosition.opacity,
6204
6143
  display: editorService.hideInlineToolbar ? 'none' : '',
6205
- transitionDuration: p.transitionDuration + 's'
6144
+ transitionDuration: viewPosition.transitionDuration + 's'
6206
6145
  }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
6207
6146
  });
6208
6147
  });
@@ -6290,10 +6229,11 @@ class StaticToolbarPlugin {
6290
6229
  const container = document.createElement('div');
6291
6230
  container.style.position = 'relative';
6292
6231
  container.style.borderRadius = 'inherit';
6293
- this.app = platformBrowser$1.createApp(jsxRuntime.jsx(core.Context, { providers: [{
6294
- provide: DropdownMenuContainer,
6295
- useValue: container
6296
- }], children: jsxRuntime.jsx(StaticToolbar, { theme: this.options.theme }) }), {
6232
+ const Context = core.createContext([{
6233
+ provide: DropdownMenuContainer,
6234
+ useValue: container
6235
+ }]);
6236
+ this.app = platformBrowser$1.createApp(jsxRuntime.jsx(Context, { children: jsxRuntime.jsx(StaticToolbar, { theme: this.options.theme }) }), {
6297
6237
  context: injector
6298
6238
  });
6299
6239
  this.options.host.appendChild(container);
@@ -6325,39 +6265,30 @@ const SuspensionToolbar = core.withAnnotation({
6325
6265
  core.onUnmounted(() => {
6326
6266
  subscription.unsubscribe();
6327
6267
  });
6328
- const [styles, updateStyles] = hooks.useProduce({
6268
+ const styles = core.reactive({
6329
6269
  top: 0,
6330
6270
  opacity: 1,
6331
6271
  });
6332
6272
  subscription.add(core$1.fromEvent(document, 'scroll').pipe(core$1.tap(() => {
6333
- updateStyles(draft => {
6334
- draft.opacity = 0;
6335
- });
6273
+ styles.opacity = 0;
6336
6274
  }), core$1.debounceTime(100), core$1.tap(() => {
6337
6275
  const rect = viewDocument.getBoundingClientRect();
6338
6276
  if (rect.top < 10) {
6339
- updateStyles(draft => {
6340
- draft.top = Math.min(-rect.top + 10, rect.height - 100);
6341
- });
6277
+ styles.top = Math.min(-rect.top + 10, rect.height - 100);
6342
6278
  }
6343
6279
  else {
6344
- updateStyles(draft => {
6345
- draft.top = 0;
6346
- });
6280
+ styles.top = 0;
6347
6281
  }
6348
6282
  }), core$1.delay(100)).subscribe(() => {
6349
- updateStyles(draft => {
6350
- draft.opacity = 1;
6351
- });
6283
+ styles.opacity = 1;
6352
6284
  }));
6353
6285
  return scopedCss.withScopedCSS(scopedId$6, () => {
6354
- const s = styles();
6355
6286
  return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme, {
6356
- suspension: s.top === 0 ? '' : 'suspension'
6287
+ suspension: styles.top === 0 ? '' : 'suspension'
6357
6288
  }], style: {
6358
- top: s.top + 'px',
6359
- opacity: s.opacity,
6360
- pointerEvents: s.opacity === 0 ? 'none' : 'initial',
6289
+ top: styles.top + 'px',
6290
+ opacity: styles.opacity,
6291
+ pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
6361
6292
  }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
6362
6293
  });
6363
6294
  });
@@ -6540,7 +6471,7 @@ function registerAtShortcut(textbus) {
6540
6471
  if (commonAncestorComponent instanceof SourceCodeComponent) {
6541
6472
  return false;
6542
6473
  }
6543
- const at = new AtComponent(textbus);
6474
+ const at = new AtComponent();
6544
6475
  commander.insert(at);
6545
6476
  selection.setPosition(at.state.slot, 0);
6546
6477
  }
@@ -6551,21 +6482,21 @@ class AtComponent extends core$1.Component {
6551
6482
  const registry = textbus.get(core$1.Registry);
6552
6483
  if (slotState) {
6553
6484
  const slot = registry.createSlot(slotState);
6554
- return new AtComponent(textbus, {
6485
+ return new AtComponent({
6555
6486
  slot
6556
6487
  });
6557
6488
  }
6558
- return new AtComponent(textbus, {
6489
+ return new AtComponent({
6559
6490
  userInfo,
6560
6491
  });
6561
6492
  }
6562
- constructor(textbus, state = {
6493
+ constructor(state = {
6563
6494
  slot: new core$1.Slot([core$1.ContentType.Text])
6564
6495
  }) {
6565
6496
  if (!state.userInfo && !state.slot) {
6566
6497
  state.slot = new core$1.Slot([core$1.ContentType.Text]);
6567
6498
  }
6568
- super(textbus, state);
6499
+ super(state);
6569
6500
  Object.defineProperty(this, "focus", {
6570
6501
  enumerable: true,
6571
6502
  configurable: true,
@@ -6588,13 +6519,13 @@ class AtComponent extends core$1.Component {
6588
6519
  enumerable: true,
6589
6520
  configurable: true,
6590
6521
  writable: true,
6591
- value: this.textbus.get(core$1.Selection)
6522
+ value: void 0
6592
6523
  });
6593
6524
  Object.defineProperty(this, "organization", {
6594
6525
  enumerable: true,
6595
6526
  configurable: true,
6596
6527
  writable: true,
6597
- value: this.textbus.get(Organization)
6528
+ value: void 0
6598
6529
  });
6599
6530
  }
6600
6531
  getSlots() {
@@ -6607,6 +6538,8 @@ class AtComponent extends core$1.Component {
6607
6538
  return [];
6608
6539
  }
6609
6540
  setup() {
6541
+ this.selection = core$1.useContext(core$1.Selection);
6542
+ this.organization = core$1.useContext(Organization);
6610
6543
  let isFocus = false;
6611
6544
  core$1.onFocus(() => {
6612
6545
  isFocus = true;
@@ -6681,7 +6614,7 @@ class AtComponent extends core$1.Component {
6681
6614
  this.focus.next(true);
6682
6615
  }
6683
6616
  });
6684
- core$1.onDestroy(() => {
6617
+ core$1.onDetach(() => {
6685
6618
  subs.unsubscribe();
6686
6619
  });
6687
6620
  }
@@ -6771,12 +6704,12 @@ const atComponentLoader = {
6771
6704
  read(element, textbus, slotParser) {
6772
6705
  const data = element.dataset.info;
6773
6706
  if (data) {
6774
- return new AtComponent(textbus, {
6707
+ return new AtComponent({
6775
6708
  userInfo: JSON.parse(decodeURIComponent(data))
6776
6709
  });
6777
6710
  }
6778
6711
  const slot = slotParser(new core$1.Slot([core$1.ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
6779
- return new AtComponent(textbus, {
6712
+ return new AtComponent({
6780
6713
  slot
6781
6714
  });
6782
6715
  }
@@ -6794,7 +6727,7 @@ class RootComponent extends core$1.Component {
6794
6727
  }
6795
6728
  static fromJSON(textbus, json) {
6796
6729
  const content = textbus.get(core$1.Registry).createSlot(json.content);
6797
- return new RootComponent(textbus, {
6730
+ return new RootComponent({
6798
6731
  content
6799
6732
  });
6800
6733
  }
@@ -6823,7 +6756,7 @@ class RootComponent extends core$1.Component {
6823
6756
  }
6824
6757
  const selection = this.textbus.get(core$1.Selection);
6825
6758
  content.retain(content.length);
6826
- const newParagraph = new ParagraphComponent(this.textbus);
6759
+ const newParagraph = new ParagraphComponent();
6827
6760
  content.insert(newParagraph);
6828
6761
  selection.setPosition(newParagraph.state.slot, 0);
6829
6762
  }
@@ -6872,7 +6805,7 @@ const rootComponentLoader = {
6872
6805
  match() {
6873
6806
  return true;
6874
6807
  },
6875
- read(element, textbus, slotParser) {
6808
+ read(element, _, slotParser) {
6876
6809
  const delta = slotParser(new core$1.Slot([
6877
6810
  core$1.ContentType.BlockComponent,
6878
6811
  core$1.ContentType.InlineComponent,
@@ -6881,7 +6814,7 @@ const rootComponentLoader = {
6881
6814
  const slot = new core$1.Slot([
6882
6815
  core$1.ContentType.BlockComponent
6883
6816
  ]);
6884
- deltaToBlock(delta, textbus).forEach(i => {
6817
+ deltaToBlock(delta).forEach(i => {
6885
6818
  slot.insert(i);
6886
6819
  });
6887
6820
  return slot;
@@ -7127,7 +7060,7 @@ function Scroll(props) {
7127
7060
  const scrollRef = core.createRef();
7128
7061
  const input = core.inject(platformBrowser.Input);
7129
7062
  const tableService = core.inject(TableService);
7130
- const [showShadow, updateShowShadow] = hooks.useProduce({
7063
+ const showShadow = core.reactive({
7131
7064
  leftEnd: false,
7132
7065
  rightEnd: false
7133
7066
  });
@@ -7137,10 +7070,8 @@ function Scroll(props) {
7137
7070
  if (props.isFocus()) {
7138
7071
  input.caret.refresh();
7139
7072
  }
7140
- updateShowShadow(draft => {
7141
- draft.leftEnd = el.scrollLeft === 0;
7142
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7143
- });
7073
+ showShadow.leftEnd = el.scrollLeft === 0;
7074
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7144
7075
  }
7145
7076
  update();
7146
7077
  const s = core$1.fromEvent(el, 'scroll').subscribe(update);
@@ -7148,15 +7079,13 @@ function Scroll(props) {
7148
7079
  });
7149
7080
  core.onUpdated(() => {
7150
7081
  const el = scrollRef.current;
7151
- updateShowShadow(draft => {
7152
- draft.leftEnd = el.scrollLeft === 0;
7153
- draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7154
- });
7082
+ showShadow.leftEnd = el.scrollLeft === 0;
7083
+ showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
7155
7084
  });
7156
7085
  return scopedCss.withScopedCSS(scopedId$3, () => {
7157
7086
  return jsxRuntime.jsx("div", { ref: [scrollRef], class: ['scroll-container', {
7158
- 'left-end': showShadow().leftEnd,
7159
- 'right-end': showShadow().rightEnd,
7087
+ 'left-end': showShadow.leftEnd,
7088
+ 'right-end': showShadow.rightEnd,
7160
7089
  'active': props.isFocus(),
7161
7090
  // 'hide-selection': isSelectColumn()
7162
7091
  }], onScroll: ev => {
@@ -7299,34 +7228,30 @@ var scopedId$1 = "vf-d4c4a9";
7299
7228
  function ResizeRow(props) {
7300
7229
  const dragLineRef = core.createRef();
7301
7230
  const tableService = core.inject(TableService);
7302
- const [styles, updateStyles] = hooks.useProduce({
7231
+ const styles = core.reactive({
7303
7232
  visible: false,
7304
7233
  top: 0
7305
7234
  });
7306
7235
  core.onMounted(() => {
7307
7236
  const sub = tableService.onInsertRowBefore.subscribe(i => {
7308
7237
  if (i === null) {
7309
- updateStyles(draft => {
7310
- draft.visible = false;
7311
- });
7238
+ styles.visible = false;
7312
7239
  return;
7313
7240
  }
7314
- updateStyles(draft => {
7315
- draft.visible = true;
7316
- if (i === -1) {
7317
- draft.top = 0;
7318
- return;
7319
- }
7320
- const row = props.tableRef.current.rows.item(i);
7321
- draft.top = row.offsetTop + row.offsetHeight;
7322
- });
7241
+ styles.visible = true;
7242
+ if (i === -1) {
7243
+ styles.top = 0;
7244
+ return;
7245
+ }
7246
+ const row = props.tableRef.current.rows.item(i);
7247
+ styles.top = row.offsetTop + row.offsetHeight;
7323
7248
  });
7324
7249
  return () => sub.unsubscribe();
7325
7250
  });
7326
7251
  return scopedCss.withScopedCSS(scopedId$1, () => {
7327
7252
  return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
7328
- display: styles().visible ? 'block' : 'none',
7329
- top: styles().top + 'px',
7253
+ display: styles.visible ? 'block' : 'none',
7254
+ top: styles.top + 'px',
7330
7255
  width: sum(props.component.state.columnsConfig) + 'px'
7331
7256
  }, class: 'drag-line' });
7332
7257
  });
@@ -7335,7 +7260,7 @@ function ResizeRow(props) {
7335
7260
  var scopedId = "vf-4a5ad1";
7336
7261
 
7337
7262
  function SelectionMask(props) {
7338
- const [styles, updateStyles] = hooks.useProduce({
7263
+ const styles = core.reactive({
7339
7264
  visible: false,
7340
7265
  left: 0,
7341
7266
  top: 0,
@@ -7349,6 +7274,7 @@ function SelectionMask(props) {
7349
7274
  });
7350
7275
  core.watch(props.component.tableSelection, update);
7351
7276
  function update() {
7277
+ var _a;
7352
7278
  const selection = props.component.tableSelection();
7353
7279
  const state = props.component.state;
7354
7280
  if (isShowMask(props.component)) {
@@ -7365,21 +7291,16 @@ function SelectionMask(props) {
7365
7291
  heightCompensation += 0.5;
7366
7292
  }
7367
7293
  const trs = Array.from(props.tableRef.current.rows);
7368
- updateStyles(draft => {
7369
- var _a;
7370
- const height = trs[selection.endRow - 1].offsetHeight ||
7371
- ((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
7372
- draft.visible = true;
7373
- draft.left = sum(state.columnsConfig.slice(0, selection.startColumn));
7374
- draft.top = trs[selection.startRow].offsetTop + topCompensation;
7375
- draft.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
7376
- draft.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - draft.top + 'px';
7377
- });
7294
+ const height = trs[selection.endRow - 1].offsetHeight ||
7295
+ ((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
7296
+ styles.visible = true;
7297
+ styles.left = sum(state.columnsConfig.slice(0, selection.startColumn));
7298
+ styles.top = trs[selection.startRow].offsetTop + topCompensation;
7299
+ styles.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
7300
+ styles.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - styles.top + 'px';
7378
7301
  }
7379
7302
  else {
7380
- updateStyles(draft => {
7381
- draft.visible = false;
7382
- });
7303
+ styles.visible = false;
7383
7304
  }
7384
7305
  }
7385
7306
  const s = props.component.changeMarker.onChange.pipe(core$1.debounceTime(30)).subscribe(() => {
@@ -7389,15 +7310,14 @@ function SelectionMask(props) {
7389
7310
  s.unsubscribe();
7390
7311
  });
7391
7312
  return scopedCss.withScopedCSS(scopedId, () => {
7392
- const style = styles();
7393
7313
  return (jsxRuntime.jsx("div", { class: "mask", style: {
7394
- display: style.visible ? 'block' : 'none',
7395
- left: style.left + 'px',
7396
- top: style.top + 'px',
7397
- right: style.right + 'px',
7398
- width: style.width,
7399
- height: style.height,
7400
- bottom: style.bottom + 'px'
7314
+ display: styles.visible ? 'block' : 'none',
7315
+ left: styles.left + 'px',
7316
+ top: styles.top + 'px',
7317
+ right: styles.right + 'px',
7318
+ width: styles.width,
7319
+ height: styles.height,
7320
+ bottom: styles.bottom + 'px'
7401
7321
  } }));
7402
7322
  });
7403
7323
  }
@@ -7612,7 +7532,7 @@ const tableComponentLoader = {
7612
7532
  core$1.ContentType.InlineComponent,
7613
7533
  core$1.ContentType.Text
7614
7534
  ]), cell).toDelta();
7615
- const results = deltaToBlock(delta, textbus);
7535
+ const results = deltaToBlock(delta);
7616
7536
  delta.attributes.forEach((value, key) => {
7617
7537
  slot.setAttribute(key, value);
7618
7538
  });
@@ -7643,7 +7563,7 @@ const tableComponentLoader = {
7643
7563
  core$1.ContentType.InlineComponent,
7644
7564
  core$1.ContentType.Text
7645
7565
  ]), cell).toDelta();
7646
- const results = deltaToBlock(delta, textbus);
7566
+ const results = deltaToBlock(delta);
7647
7567
  delta.attributes.forEach((value, key) => {
7648
7568
  slot.setAttribute(key, value);
7649
7569
  });
@@ -7670,7 +7590,7 @@ const tableComponentLoader = {
7670
7590
  layoutWidth[i] = layoutWidth[i] || 100;
7671
7591
  }
7672
7592
  layoutWidth.length = length;
7673
- return new TableComponent(textbus, {
7593
+ return new TableComponent({
7674
7594
  columnsConfig: layoutWidth,
7675
7595
  mergeConfig: cells.mergedConfig,
7676
7596
  rows: cells.table.map(i => {
@@ -7759,7 +7679,6 @@ TableSelectionAwarenessDelegate = __decorate([
7759
7679
 
7760
7680
  function TimelineComponentView(props) {
7761
7681
  const adapter = core.inject(platformBrowser.DomAdapter);
7762
- const textbus = core.inject(core$1.Textbus);
7763
7682
  const isOutput = useOutput();
7764
7683
  const isReadonly = useReadonly();
7765
7684
  return () => {
@@ -7772,7 +7691,7 @@ function TimelineComponentView(props) {
7772
7691
  backgroundColor: item.theme,
7773
7692
  } }), !isOutput() && !isReadonly() && jsxRuntime.jsxs("div", { class: "xnote-timeline-tools", children: [jsxRuntime.jsx(Button, { class: "xnote-timeline-add xnote-icon-plus", onClick: () => {
7774
7693
  const index = component.state.items.indexOf(item) + 1;
7775
- component.state.items.splice(index, 0, createTimelineItem(textbus, item.theme));
7694
+ component.state.items.splice(index, 0, createTimelineItem(item.theme));
7776
7695
  } }), jsxRuntime.jsx(Button, { class: "xnote-timeline-add xnote-icon-bin", onClick: () => {
7777
7696
  const index = component.state.items.indexOf(item);
7778
7697
  component.state.items.splice(index, 1);
@@ -7788,8 +7707,8 @@ const timelineComponentLoader = {
7788
7707
  match(element) {
7789
7708
  return element.className === 'xnote-timeline';
7790
7709
  },
7791
- read(element, context, slotParser) {
7792
- return new TimelineComponent(context, {
7710
+ read(element, _, slotParser) {
7711
+ return new TimelineComponent({
7793
7712
  items: Array.from(element.children).map(child => {
7794
7713
  const slot = new core$1.Slot([
7795
7714
  core$1.ContentType.BlockComponent
@@ -7805,7 +7724,6 @@ const timelineComponentLoader = {
7805
7724
 
7806
7725
  function StepComponentView(props) {
7807
7726
  const adapter = core.inject(platformBrowser.DomAdapter);
7808
- const textbus = core.inject(core$1.Textbus);
7809
7727
  const isOutput = useOutput();
7810
7728
  const isReadonly = useReadonly();
7811
7729
  return () => {
@@ -7831,7 +7749,7 @@ function StepComponentView(props) {
7831
7749
  }
7832
7750
  }, children: index + 1 })] }), !isOutput() && !isReadonly() && jsxRuntime.jsxs("div", { class: "xnote-step-tools", children: [jsxRuntime.jsx(Button, { class: "xnote-step-add xnote-icon-plus", onClick: () => {
7833
7751
  const index = component.state.items.indexOf(item) + 1;
7834
- component.state.items.splice(index, 0, createStepItem(textbus));
7752
+ component.state.items.splice(index, 0, createStepItem());
7835
7753
  } }), jsxRuntime.jsx(Button, { class: "xnote-step-add xnote-icon-bin", onClick: () => {
7836
7754
  const index = component.state.items.indexOf(item);
7837
7755
  component.state.items.splice(index, 1);
@@ -7847,8 +7765,8 @@ const stepComponentLoader = {
7847
7765
  match(element) {
7848
7766
  return element.dataset.component === StepComponent.componentName;
7849
7767
  },
7850
- read(element, context, slotParser) {
7851
- return new StepComponent(context, {
7768
+ read(element, _, slotParser) {
7769
+ return new StepComponent({
7852
7770
  step: Number(element.dataset.step) || 0,
7853
7771
  items: Array.from(element.children).map(child => {
7854
7772
  const slot = new core$1.Slot([
@@ -8130,7 +8048,7 @@ class Editor extends core$1.Textbus {
8130
8048
  rootComp = this.createModel(config.content);
8131
8049
  }
8132
8050
  else {
8133
- rootComp = new RootComponent(this, {
8051
+ rootComp = new RootComponent({
8134
8052
  content: new core$1.Slot([core$1.ContentType.BlockComponent])
8135
8053
  });
8136
8054
  }
@@ -8166,11 +8084,11 @@ class Editor extends core$1.Textbus {
8166
8084
  core$1.ContentType.BlockComponent
8167
8085
  ]);
8168
8086
  if (doc instanceof core$1.Slot) {
8169
- deltaToBlock(doc.toDelta(), this).forEach(i => {
8087
+ deltaToBlock(doc.toDelta()).forEach(i => {
8170
8088
  content.insert(i);
8171
8089
  });
8172
8090
  }
8173
- return new RootComponent(this, {
8091
+ return new RootComponent({
8174
8092
  content
8175
8093
  });
8176
8094
  }