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