@textbus/xnote 0.0.1-alpha.14 → 0.0.1-alpha.16

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
@@ -12,7 +12,7 @@ var color = require('@tanbo/color');
12
12
  var adapterViewfly = require('@textbus/adapter-viewfly');
13
13
  var collaborate = require('@textbus/collaborate');
14
14
 
15
- var scopedId$l = "vf-3d0183";
15
+ var scopedId$m = "vf-3d0183";
16
16
 
17
17
  /******************************************************************************
18
18
  Copyright (c) Microsoft Corporation.
@@ -133,7 +133,7 @@ function Button(props) {
133
133
  subscription.unsubscribe();
134
134
  });
135
135
  }
136
- return scopedCss.withScopedCSS(scopedId$l, () => {
136
+ return scopedCss.withScopedCSS(scopedId$m, () => {
137
137
  return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
138
138
  'btn',
139
139
  {
@@ -145,10 +145,10 @@ function Button(props) {
145
145
  });
146
146
  }
147
147
 
148
- var scopedId$k = "vf-ac7e8d";
148
+ var scopedId$l = "vf-ac7e8d";
149
149
 
150
150
  function ComponentToolbar(props) {
151
- return scopedCss.withScopedCSS(scopedId$k, () => {
151
+ return scopedCss.withScopedCSS(scopedId$l, () => {
152
152
  return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
153
153
  'toolbar',
154
154
  {
@@ -158,15 +158,15 @@ function ComponentToolbar(props) {
158
158
  });
159
159
  }
160
160
 
161
- var scopedId$j = "vf-ede279";
161
+ var scopedId$k = "vf-ede279";
162
162
 
163
163
  function Divider() {
164
- return scopedCss.withScopedCSS(scopedId$j, () => {
164
+ return scopedCss.withScopedCSS(scopedId$k, () => {
165
165
  return jsxRuntime.jsx("div", { class: "divider" });
166
166
  });
167
167
  }
168
168
 
169
- var scopedId$i = "vf-4c1803";
169
+ var scopedId$j = "vf-4c1803";
170
170
 
171
171
  function DragResize(props) {
172
172
  const isShow = core.createSignal(false);
@@ -274,16 +274,16 @@ function DragResize(props) {
274
274
  unUp.unsubscribe();
275
275
  });
276
276
  }
277
- return scopedCss.withScopedCSS(scopedId$i, () => {
277
+ return scopedCss.withScopedCSS(scopedId$j, () => {
278
278
  return (jsxRuntime.jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsxRuntime.jsx("div", { class: "container", ref: ref, children: props.children }), jsxRuntime.jsxs("div", { class: ['resize-tool', {
279
279
  active: isShow()
280
280
  }], children: [jsxRuntime.jsxs("div", { class: "mask", ref: mask, children: [component.state.width, "*", component.state.height] }), jsxRuntime.jsxs("div", { class: "btn-group", ref: btnGroup, onMousedown: drag, children: [jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" })] })] })] }));
281
281
  });
282
282
  }
283
283
 
284
- var scopedId$h = "vf-a99c5e";
284
+ var scopedId$i = "vf-a99c5e";
285
285
 
286
- var scopedId$g = "vf-ab6f55";
286
+ var scopedId$h = "vf-ab6f55";
287
287
 
288
288
  const DropdownMenuPortal = core.withAnnotation({
289
289
  providers: [
@@ -375,7 +375,7 @@ const DropdownMenuPortal = core.withAnnotation({
375
375
  dropdownContextService.canHide = true;
376
376
  dropdownContextService.hide();
377
377
  }
378
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$g, () => {
378
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$h, () => {
379
379
  return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
380
380
  width: props.width
381
381
  }, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", children: props.children }) }));
@@ -441,7 +441,7 @@ const Dropdown = core.withAnnotation({
441
441
  dropdownContextService.hide(false);
442
442
  }
443
443
  },
444
- $render: scopedCss.withScopedCSS(scopedId$h, () => {
444
+ $render: scopedCss.withScopedCSS(scopedId$i, () => {
445
445
  return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsxRuntime.jsx(DropdownMenuPortal, { noTrigger: props.trigger === 'none', width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
446
446
  props.menu.map(menu => {
447
447
  return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
@@ -457,6 +457,42 @@ const Dropdown = core.withAnnotation({
457
457
  };
458
458
  });
459
459
 
460
+ var scopedId$g = "vf-9dad68";
461
+
462
+ function Keymap(props) {
463
+ const arr = [];
464
+ const keymap = props.keymap;
465
+ if (keymap.ctrlKey) {
466
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-command" }) : 'Ctrl');
467
+ }
468
+ if (keymap.shiftKey) {
469
+ if (arr.length) {
470
+ arr.push('+');
471
+ }
472
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-shift" }) : 'Shift');
473
+ }
474
+ if (keymap.altKey) {
475
+ if (arr.length) {
476
+ arr.push('+');
477
+ }
478
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-opt" }) : 'Alt');
479
+ }
480
+ if (keymap.key) {
481
+ if (arr.length) {
482
+ arr.push('+');
483
+ }
484
+ if (Array.isArray(keymap.key)) {
485
+ arr.push(jsxRuntime.jsx("span", { children: keymap.key.join('/') }));
486
+ }
487
+ else {
488
+ arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
489
+ }
490
+ }
491
+ return scopedCss.withScopedCSS(scopedId$g, () => {
492
+ return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
493
+ });
494
+ }
495
+
460
496
  var scopedId$f = "vf-acaa5f";
461
497
 
462
498
  function MenuHeading(props) {
@@ -465,7 +501,7 @@ function MenuHeading(props) {
465
501
  });
466
502
  }
467
503
 
468
- var scopedId$e = "vf-678daa";
504
+ var scopedId$e = "vf-c3b9dc";
469
505
 
470
506
  function MenuItem(props) {
471
507
  const dropdownContextService = core.inject(exports.DropdownContextService, null);
@@ -486,7 +522,7 @@ function MenuItem(props) {
486
522
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
487
523
  }
488
524
  return scopedCss.withScopedCSS(scopedId$e, () => {
489
- return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), props.arrow ?
525
+ return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { class: "menu-item-content", children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), jsxRuntime.jsx("div", { children: props.desc })] }), props.arrow ?
490
526
  jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
491
527
  jsxRuntime.jsx("div", { class: [
492
528
  'menu-check',
@@ -605,10 +641,14 @@ function registerHeadingShortcut(textbus) {
605
641
  const selection = textbus.get(core$1.Selection);
606
642
  keyboard.addShortcut({
607
643
  keymap: {
608
- key: '123456'.split(''),
644
+ key: '0123456'.split(''),
609
645
  ctrlKey: true
610
646
  },
611
647
  action(key) {
648
+ if (key === '0') {
649
+ commander.unApplyAttribute(headingAttr);
650
+ return;
651
+ }
612
652
  commander.applyAttribute(headingAttr, 'h' + key);
613
653
  }
614
654
  });
@@ -699,6 +739,55 @@ BlockquoteComponent.zenCoding = {
699
739
  };
700
740
  }
701
741
  };
742
+ function toBlockquote(textbus) {
743
+ const query = textbus.get(core$1.Query);
744
+ const commander = textbus.get(core$1.Commander);
745
+ const selection = textbus.get(core$1.Selection);
746
+ const state = query.queryComponent(BlockquoteComponent);
747
+ if (state.state === core$1.QueryStateType.Enabled) {
748
+ const current = state.value;
749
+ const parent = current.parent;
750
+ const index = parent.indexOf(current);
751
+ parent.retain(index);
752
+ commander.removeComponent(current);
753
+ current.__slots__.get(0).sliceContent().forEach(i => {
754
+ parent.insert(i);
755
+ });
756
+ }
757
+ else {
758
+ const block = new BlockquoteComponent(textbus);
759
+ const slot = block.state.slot;
760
+ if (selection.startSlot === selection.endSlot) {
761
+ const parentComponent = selection.startSlot.parent;
762
+ const parentSlot = parentComponent.parent;
763
+ const position = parentSlot.indexOf(parentComponent);
764
+ slot.insert(parentComponent);
765
+ parentSlot.retain(position);
766
+ parentSlot.insert(block);
767
+ }
768
+ else {
769
+ const commonAncestorSlot = selection.commonAncestorSlot;
770
+ const scope = selection.getCommonAncestorSlotScope();
771
+ commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
772
+ slot.insert(i);
773
+ });
774
+ commonAncestorSlot.retain(scope.startOffset);
775
+ commonAncestorSlot.insert(block);
776
+ }
777
+ }
778
+ }
779
+ function registerBlockquoteShortcut(textbus) {
780
+ const keyboard = textbus.get(core$1.Keyboard);
781
+ keyboard.addShortcut({
782
+ keymap: {
783
+ ctrlKey: true,
784
+ key: '\''
785
+ },
786
+ action() {
787
+ toBlockquote(textbus);
788
+ }
789
+ });
790
+ }
702
791
  function BlockquoteView(props) {
703
792
  const adapter = core.inject(platformBrowser.DomAdapter);
704
793
  const readonly = useReadonly();
@@ -711,8 +800,8 @@ function BlockquoteView(props) {
711
800
  };
712
801
  }
713
802
  const blockquoteComponentLoader = {
714
- match(element) {
715
- return element.tagName === 'BLOCKQUOTE';
803
+ match(element, returnableContentTypes) {
804
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
716
805
  },
717
806
  read(element, textbus, slotParser) {
718
807
  const delta = slotParser(new core$1.Slot([
@@ -865,8 +954,8 @@ function ParagraphView(props) {
865
954
  };
866
955
  }
867
956
  const paragraphComponentLoader = {
868
- match(element) {
869
- return element.dataset.compoment === ParagraphComponent.componentName || /P|H[1-6]/.test(element.tagName);
957
+ match(element, returnableContentTypes) {
958
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.dataset.compoment === ParagraphComponent.componentName || /P|H[1-6]/.test(element.tagName);
870
959
  },
871
960
  read(element, textbus, slotParser) {
872
961
  const content = /P|H[1-6]/.test(element.tagName) ? element : element.children[0];
@@ -945,6 +1034,15 @@ const languageList = [{
945
1034
  }, {
946
1035
  label: 'Go',
947
1036
  value: 'Go'
1037
+ }, {
1038
+ label: 'Kotlin',
1039
+ value: 'kotlin'
1040
+ }, {
1041
+ label: 'Python',
1042
+ value: 'python'
1043
+ }, {
1044
+ label: 'PHP',
1045
+ value: 'php'
948
1046
  }, {
949
1047
  label: 'JSON',
950
1048
  value: 'JSON',
@@ -987,11 +1085,16 @@ const languageList = [{
987
1085
  }, {
988
1086
  label: 'Dart',
989
1087
  value: 'dart',
1088
+ }, {
1089
+ label: 'Rust',
1090
+ value: 'rust',
990
1091
  }, {
991
1092
  label: '',
992
1093
  value: '',
993
1094
  }];
994
1095
  const sourceCodeThemes = [
1096
+ 'xnote-dark',
1097
+ 'xnote-dark-blue',
995
1098
  'github',
996
1099
  'atom-one-dark',
997
1100
  'foundation',
@@ -1289,7 +1392,7 @@ function SourceCodeView(props) {
1289
1392
  }
1290
1393
  const input = core.inject(platformBrowser.Input);
1291
1394
  function updateCaret() {
1292
- input.caret.refresh(false);
1395
+ input.caret.refresh();
1293
1396
  }
1294
1397
  const readonly = useReadonly();
1295
1398
  const output = useOutput();
@@ -1409,9 +1512,10 @@ function SourceCodeView(props) {
1409
1512
  };
1410
1513
  }
1411
1514
  const sourceCodeComponentLoader = {
1412
- match(element) {
1413
- return (element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
1414
- element.tagName === 'PRE';
1515
+ match(element, returnableContentTypes) {
1516
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
1517
+ ((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
1518
+ element.tagName === 'PRE');
1415
1519
  },
1416
1520
  read(el, textbus) {
1417
1521
  let slots = [];
@@ -1609,25 +1713,25 @@ function AttrTool(props) {
1609
1713
  const states = checkStates();
1610
1714
  return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
1611
1715
  {
1612
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
1716
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', ctrlKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
1613
1717
  value: 't-l'
1614
1718
  }, {
1615
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
1719
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', ctrlKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
1616
1720
  value: 't-r'
1617
1721
  }, {
1618
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
1722
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', ctrlKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
1619
1723
  value: 't-c'
1620
1724
  }, {
1621
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
1725
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', ctrlKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
1622
1726
  value: 't-j'
1623
1727
  }, {
1624
1728
  label: jsxRuntime.jsx(Divider, {}),
1625
1729
  value: ''
1626
1730
  }, {
1627
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
1731
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '<', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
1628
1732
  value: 'i+'
1629
1733
  }, {
1630
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
1734
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '>', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
1631
1735
  value: 'i-'
1632
1736
  }
1633
1737
  ], children: props.children || jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
@@ -1656,17 +1760,18 @@ class TableComponent extends core$1.Component {
1656
1760
  });
1657
1761
  }
1658
1762
  constructor(textbus, state = {
1659
- layoutWidth: Array.from({ length: 3 }).fill(100),
1763
+ layoutWidth: Array.from({ length: 5 }).fill(100),
1660
1764
  rows: Array.from({ length: 3 }).map(() => {
1661
1765
  return {
1662
1766
  height: defaultRowHeight,
1663
- cells: Array.from({ length: 3 }).map(() => {
1767
+ cells: Array.from({ length: 5 }).map(() => {
1768
+ const p = new ParagraphComponent(textbus);
1769
+ const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
1770
+ slot.insert(p);
1664
1771
  return {
1665
1772
  rowspan: 1,
1666
1773
  colspan: 1,
1667
- slot: new core$1.Slot([
1668
- core$1.ContentType.BlockComponent
1669
- ])
1774
+ slot
1670
1775
  };
1671
1776
  })
1672
1777
  };
@@ -1767,31 +1872,31 @@ class TableComponent extends core$1.Component {
1767
1872
  }
1768
1873
  });
1769
1874
  }
1770
- afterContentCheck() {
1771
- const selection = this.selection;
1772
- const rows = this.state.rows;
1773
- rows.forEach(row => {
1774
- row.cells.forEach(cell => {
1775
- const slot = cell.slot;
1776
- if (slot.isEmpty) {
1777
- const childSlot = new core$1.Slot([
1778
- core$1.ContentType.Text,
1779
- core$1.ContentType.InlineComponent
1780
- ]);
1781
- const p = new ParagraphComponent(this.textbus, {
1782
- slot: childSlot
1783
- });
1784
- slot.insert(p);
1785
- if (slot === selection.anchorSlot) {
1786
- selection.setAnchor(childSlot, 0);
1787
- }
1788
- if (slot === selection.focusSlot) {
1789
- selection.setFocus(childSlot, 0);
1790
- }
1791
- }
1792
- });
1793
- });
1794
- }
1875
+ // afterContentCheck() {
1876
+ // const selection = this.selection
1877
+ // const rows = this.state.rows
1878
+ // rows.forEach(row => {
1879
+ // row.cells.forEach(cell => {
1880
+ // const slot = cell.slot
1881
+ // if (slot.isEmpty) {
1882
+ // const childSlot = new Slot([
1883
+ // ContentType.Text,
1884
+ // ContentType.InlineComponent
1885
+ // ])
1886
+ // const p = new ParagraphComponent(this.textbus, {
1887
+ // slot: childSlot
1888
+ // })
1889
+ // slot.insert(p)
1890
+ // if (slot === selection.anchorSlot) {
1891
+ // selection.setAnchor(childSlot, 0)
1892
+ // }
1893
+ // if (slot === selection.focusSlot) {
1894
+ // selection.setFocus(childSlot, 0)
1895
+ // }
1896
+ // }
1897
+ // })
1898
+ // })
1899
+ // }
1795
1900
  deleteColumn(index) {
1796
1901
  this.state.layoutWidth.splice(index, 1);
1797
1902
  this.state.rows.forEach(row => {
@@ -2046,6 +2151,40 @@ const todolistComponentLoader = {
2046
2151
  }
2047
2152
  };
2048
2153
 
2154
+ function toList(textbus, type) {
2155
+ const commander = textbus.get(core$1.Commander);
2156
+ commander.transform({
2157
+ targetType: ListComponent.type,
2158
+ slotFactory() {
2159
+ return new core$1.Slot([
2160
+ core$1.ContentType.InlineComponent,
2161
+ core$1.ContentType.Text
2162
+ ]);
2163
+ },
2164
+ stateFactory(slots) {
2165
+ return slots.map((slot, index) => {
2166
+ return new ListComponent(textbus, {
2167
+ type,
2168
+ reorder: index === 0,
2169
+ slot
2170
+ });
2171
+ });
2172
+ }
2173
+ });
2174
+ }
2175
+ function registerListShortcut(textbus) {
2176
+ const keyboard = textbus.get(core$1.Keyboard);
2177
+ keyboard.addShortcut({
2178
+ keymap: {
2179
+ key: ['o', 'u'],
2180
+ ctrlKey: true,
2181
+ shiftKey: true
2182
+ },
2183
+ action(key) {
2184
+ toList(textbus, key === 'o' ? 'OrderedList' : 'UnorderedList');
2185
+ }
2186
+ });
2187
+ }
2049
2188
  class ListComponent extends core$1.Component {
2050
2189
  static fromJSON(textbus, json) {
2051
2190
  return new ListComponent(textbus, {
@@ -2132,7 +2271,7 @@ class ListComponent extends core$1.Component {
2132
2271
  key: 'Tab'
2133
2272
  },
2134
2273
  action: () => {
2135
- updateAfterList(this);
2274
+ Promise.resolve().then(() => updateAfterList(this));
2136
2275
  return false;
2137
2276
  }
2138
2277
  });
@@ -2276,8 +2415,8 @@ function ListComponentView(props) {
2276
2415
  };
2277
2416
  }
2278
2417
  const listComponentLoader = {
2279
- match(element) {
2280
- return element.tagName === 'UL' || element.tagName === 'OL';
2418
+ match(element, returnableContentTypes) {
2419
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.tagName === 'UL' || element.tagName === 'OL');
2281
2420
  },
2282
2421
  read(element, textbus, slotParser) {
2283
2422
  const type = element.tagName === 'OL' ? 'OrderedList' : 'UnorderedList';
@@ -2450,62 +2589,10 @@ function useBlockTransform() {
2450
2589
  break;
2451
2590
  case 'ol':
2452
2591
  case 'ul':
2453
- {
2454
- commander.transform({
2455
- targetType: ListComponent.type,
2456
- slotFactory() {
2457
- return new core$1.Slot([
2458
- core$1.ContentType.InlineComponent,
2459
- core$1.ContentType.Text
2460
- ]);
2461
- },
2462
- stateFactory(slots) {
2463
- return slots.map((slot, index) => {
2464
- return new ListComponent(textbus, {
2465
- type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
2466
- reorder: index === 0,
2467
- slot
2468
- });
2469
- });
2470
- }
2471
- });
2472
- }
2592
+ toList(textbus, value === 'ol' ? 'OrderedList' : 'UnorderedList');
2473
2593
  break;
2474
2594
  case 'blockquote':
2475
- {
2476
- const state = query.queryComponent(BlockquoteComponent);
2477
- if (state.state === core$1.QueryStateType.Enabled) {
2478
- const current = state.value;
2479
- const parent = current.parent;
2480
- const index = parent.indexOf(current);
2481
- parent.retain(index);
2482
- commander.removeComponent(current);
2483
- current.__slots__.get(0).sliceContent().forEach(i => {
2484
- parent.insert(i);
2485
- });
2486
- }
2487
- else {
2488
- const block = new BlockquoteComponent(textbus);
2489
- const slot = block.state.slot;
2490
- if (selection.startSlot === selection.endSlot) {
2491
- const parentComponent = selection.startSlot.parent;
2492
- const parentSlot = parentComponent.parent;
2493
- const position = parentSlot.indexOf(parentComponent);
2494
- slot.insert(parentComponent);
2495
- parentSlot.retain(position);
2496
- parentSlot.insert(block);
2497
- }
2498
- else {
2499
- const commonAncestorSlot = selection.commonAncestorSlot;
2500
- const scope = selection.getCommonAncestorSlotScope();
2501
- commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
2502
- slot.insert(i);
2503
- });
2504
- commonAncestorSlot.retain(scope.startOffset);
2505
- commonAncestorSlot.insert(block);
2506
- }
2507
- }
2508
- }
2595
+ toBlockquote(textbus);
2509
2596
  break;
2510
2597
  case 'sourceCode':
2511
2598
  {
@@ -2622,25 +2709,46 @@ function BlockTool() {
2622
2709
  }
2623
2710
  return (jsxRuntime.jsx(Dropdown, { onCheck: transform, trigger: 'hover', menu: [
2624
2711
  {
2625
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), checked: states.paragraph, children: "\u6B63\u6587" }),
2712
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2713
+ ctrlKey: true,
2714
+ key: '0'
2715
+ } }), checked: states.paragraph, children: "\u6B63\u6587" }),
2626
2716
  value: 'paragraph'
2627
2717
  }, {
2628
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
2718
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2719
+ ctrlKey: true,
2720
+ key: '1'
2721
+ } }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
2629
2722
  value: 'h1'
2630
2723
  }, {
2631
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
2724
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2725
+ ctrlKey: true,
2726
+ key: '2'
2727
+ } }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
2632
2728
  value: 'h2'
2633
2729
  }, {
2634
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
2730
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2731
+ ctrlKey: true,
2732
+ key: '3'
2733
+ } }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
2635
2734
  value: 'h3'
2636
2735
  }, {
2637
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
2736
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2737
+ ctrlKey: true,
2738
+ key: '4'
2739
+ } }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
2638
2740
  value: 'h4'
2639
2741
  }, {
2640
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
2742
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2743
+ ctrlKey: true,
2744
+ key: '5'
2745
+ } }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
2641
2746
  value: 'h5'
2642
2747
  }, {
2643
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
2748
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2749
+ ctrlKey: true,
2750
+ key: '6'
2751
+ } }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
2644
2752
  value: 'h6'
2645
2753
  }, {
2646
2754
  label: jsxRuntime.jsx(Divider, {}),
@@ -2649,13 +2757,13 @@ function BlockTool() {
2649
2757
  label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), checked: states.todolist, children: "\u5F85\u529E\u4E8B\u9879" }),
2650
2758
  value: 'todolist'
2651
2759
  }, {
2652
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
2760
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'O', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
2653
2761
  value: 'ol'
2654
2762
  }, {
2655
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
2763
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'U', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
2656
2764
  value: 'ul'
2657
2765
  }, {
2658
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
2766
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '\'', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
2659
2767
  value: 'blockquote'
2660
2768
  }, {
2661
2769
  label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }), checked: states.sourceCode, children: "\u4EE3\u7801\u5757" }),
@@ -3090,7 +3198,7 @@ function ColorTool(props) {
3090
3198
  ];
3091
3199
  return scopedCss.withScopedCSS(scopedId$a, () => {
3092
3200
  const vm = viewModel();
3093
- return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
3201
+ return (jsxRuntime.jsx(Dropdown, { style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
3094
3202
  active: textColor() === ''
3095
3203
  }, onClick: () => {
3096
3204
  var _a;
@@ -3560,7 +3668,9 @@ function InsertTool(props) {
3560
3668
  {
3561
3669
  const table = new TableComponent(textbus);
3562
3670
  insertComponent(table);
3563
- selection.setPosition(table.state.rows[0].cells[0].slot, 0);
3671
+ textbus.nextTick(() => {
3672
+ selection.selectFirstPosition(table, true, true);
3673
+ });
3564
3674
  }
3565
3675
  break;
3566
3676
  case 'todolist':
@@ -4589,7 +4699,7 @@ function Scroll(props) {
4589
4699
  const el = scrollRef.current;
4590
4700
  function update() {
4591
4701
  if (props.isFocus()) {
4592
- input.caret.refresh(false);
4702
+ input.caret.refresh();
4593
4703
  }
4594
4704
  updateShowShadow(draft => {
4595
4705
  draft.leftEnd = el.scrollLeft === 0;
@@ -4881,9 +4991,6 @@ const TableComponentView = core.withAnnotation({
4881
4991
  }
4882
4992
  rowMapping.set(row, Math.random());
4883
4993
  });
4884
- Promise.resolve().then(() => {
4885
- props.component.afterContentCheck();
4886
- });
4887
4994
  if (readonly() || output()) {
4888
4995
  return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
4889
4996
  'xnote-table-content',
@@ -4948,6 +5055,8 @@ const tableComponentLoader = {
4948
5055
  });
4949
5056
  const delta = slotParser(new core$1.Slot([
4950
5057
  core$1.ContentType.BlockComponent,
5058
+ core$1.ContentType.InlineComponent,
5059
+ core$1.ContentType.Text
4951
5060
  ]), cell).toDelta();
4952
5061
  const results = deltaToBlock(delta, textbus);
4953
5062
  results.forEach(i => {
@@ -4973,6 +5082,8 @@ const tableComponentLoader = {
4973
5082
  });
4974
5083
  const delta = slotParser(new core$1.Slot([
4975
5084
  core$1.ContentType.BlockComponent,
5085
+ core$1.ContentType.InlineComponent,
5086
+ core$1.ContentType.Text
4976
5087
  ]), cell).toDelta();
4977
5088
  const results = deltaToBlock(delta, textbus);
4978
5089
  results.forEach(i => {
@@ -5197,6 +5308,8 @@ class Editor extends core$1.Textbus {
5197
5308
  registerTextAlignShortcut(textbus);
5198
5309
  registerTextIndentShortcut(textbus);
5199
5310
  registerAtShortcut(textbus);
5311
+ registerListShortcut(textbus);
5312
+ registerBlockquoteShortcut(textbus);
5200
5313
  } }, editorConfig));
5201
5314
  this.editorConfig = editorConfig;
5202
5315
  this.translator = new platformBrowser$1.OutputTranslator();
@@ -5262,6 +5375,7 @@ exports.ImageComponent = ImageComponent;
5262
5375
  exports.ImageView = ImageView;
5263
5376
  exports.InsertTool = InsertTool;
5264
5377
  exports.ItalicTool = ItalicTool;
5378
+ exports.Keymap = Keymap;
5265
5379
  exports.LeftToolbar = LeftToolbar;
5266
5380
  exports.LeftToolbarPlugin = LeftToolbarPlugin;
5267
5381
  exports.LinkTool = LinkTool;
@@ -5319,10 +5433,12 @@ exports.linkFormatter = linkFormatter;
5319
5433
  exports.listComponentLoader = listComponentLoader;
5320
5434
  exports.paragraphComponentLoader = paragraphComponentLoader;
5321
5435
  exports.registerAtShortcut = registerAtShortcut;
5436
+ exports.registerBlockquoteShortcut = registerBlockquoteShortcut;
5322
5437
  exports.registerBoldShortcut = registerBoldShortcut;
5323
5438
  exports.registerCodeShortcut = registerCodeShortcut;
5324
5439
  exports.registerHeadingShortcut = registerHeadingShortcut;
5325
5440
  exports.registerItalicShortcut = registerItalicShortcut;
5441
+ exports.registerListShortcut = registerListShortcut;
5326
5442
  exports.registerStrikeThroughShortcut = registerStrikeThroughShortcut;
5327
5443
  exports.registerTextAlignShortcut = registerTextAlignShortcut;
5328
5444
  exports.registerTextIndentShortcut = registerTextIndentShortcut;
@@ -5337,6 +5453,8 @@ exports.textAlignAttr = textAlignAttr;
5337
5453
  exports.textAlignAttrLoader = textAlignAttrLoader;
5338
5454
  exports.textIndentAttr = textIndentAttr;
5339
5455
  exports.textIndentAttrLoader = textIndentAttrLoader;
5456
+ exports.toBlockquote = toBlockquote;
5457
+ exports.toList = toList;
5340
5458
  exports.todolistComponentLoader = todolistComponentLoader;
5341
5459
  exports.toggleBold = toggleBold;
5342
5460
  exports.toggleCode = toggleCode;