@textbus/xnote 0.0.1-alpha.3 → 0.0.1-alpha.5

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.
@@ -3,13 +3,13 @@ import { withScopedCSS } from '@viewfly/scoped-css';
3
3
  import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onMounted, InjectionToken, viewfly, createDynamicRef, onUpdated, getCurrentInstance, watch, ReflectiveInjector } from '@viewfly/core';
4
4
  import { Subject, Selection, fromEvent, Subscription, Attribute, Keyboard, Commander, Controller, ContentType, Component, Registry, Slot, useContext, onBreak, createVNode, BehaviorSubject, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, Query, QueryStateType, onContentInsert, onFocusIn, onFocusOut, onGetRanges, Formatter, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, merge, debounceTime, throttleTime, delay, onCompositionStart } from '@textbus/core';
5
5
  import { VIEW_CONTAINER, DomAdapter, Input, SelectionBridge, VIEW_DOCUMENT, BrowserModule, Parser } from '@textbus/platform-browser';
6
- import { createPortal, DomRenderer, createApp } from '@viewfly/platform-browser';
6
+ import { createPortal, DomRenderer, createApp, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
7
7
  import { useProduce } from '@viewfly/hooks';
8
8
  import highlightjs from 'highlight.js';
9
- import { Adapter } from '@textbus/adapter-viewfly';
9
+ import { ViewflyAdapter, ViewflyVDomAdapter } from '@textbus/adapter-viewfly';
10
10
  import { CollaborateModule } from '@textbus/collaborate';
11
11
 
12
- var exportedId$k = "vf-69b4db";
12
+ var css$j = undefined;
13
13
 
14
14
  /******************************************************************************
15
15
  Copyright (c) Microsoft Corporation.
@@ -56,18 +56,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
56
56
 
57
57
  let DropdownService = class DropdownService {
58
58
  constructor() {
59
- Object.defineProperty(this, "onSiblingOpen", {
60
- enumerable: true,
61
- configurable: true,
62
- writable: true,
63
- value: void 0
64
- });
65
- Object.defineProperty(this, "siblingOpenEvent", {
66
- enumerable: true,
67
- configurable: true,
68
- writable: true,
69
- value: new Subject()
70
- });
59
+ this.siblingOpenEvent = new Subject();
71
60
  this.onSiblingOpen = this.siblingOpenEvent.asObservable();
72
61
  }
73
62
  notify(id) {
@@ -85,60 +74,14 @@ var DropdownContextService_1;
85
74
  let i = 0;
86
75
  let DropdownContextService = DropdownContextService_1 = class DropdownContextService {
87
76
  constructor(dropdownService, injector) {
88
- Object.defineProperty(this, "dropdownService", {
89
- enumerable: true,
90
- configurable: true,
91
- writable: true,
92
- value: dropdownService
93
- });
94
- Object.defineProperty(this, "injector", {
95
- enumerable: true,
96
- configurable: true,
97
- writable: true,
98
- value: injector
99
- });
100
- Object.defineProperty(this, "id", {
101
- enumerable: true,
102
- configurable: true,
103
- writable: true,
104
- value: i
105
- });
106
- Object.defineProperty(this, "isOpen", {
107
- enumerable: true,
108
- configurable: true,
109
- writable: true,
110
- value: false
111
- });
112
- Object.defineProperty(this, "onOpenStateChange", {
113
- enumerable: true,
114
- configurable: true,
115
- writable: true,
116
- value: void 0
117
- });
118
- Object.defineProperty(this, "canHide", {
119
- enumerable: true,
120
- configurable: true,
121
- writable: true,
122
- value: true
123
- });
124
- Object.defineProperty(this, "openStateChangeEvent", {
125
- enumerable: true,
126
- configurable: true,
127
- writable: true,
128
- value: new Subject()
129
- });
130
- Object.defineProperty(this, "timer", {
131
- enumerable: true,
132
- configurable: true,
133
- writable: true,
134
- value: null
135
- });
136
- Object.defineProperty(this, "parentDropdownContextService", {
137
- enumerable: true,
138
- configurable: true,
139
- writable: true,
140
- value: this.injector.get(DropdownContextService_1, InjectFlags.SkipSelf, null)
141
- });
77
+ this.dropdownService = dropdownService;
78
+ this.injector = injector;
79
+ this.id = i;
80
+ this.isOpen = false;
81
+ this.canHide = true;
82
+ this.openStateChangeEvent = new Subject();
83
+ this.timer = null;
84
+ this.parentDropdownContextService = this.injector.get(DropdownContextService_1, InjectFlags.SkipSelf, null);
142
85
  this.onOpenStateChange = this.openStateChangeEvent.asObservable();
143
86
  dropdownService.onSiblingOpen.subscribe(id => {
144
87
  if (id === this.id) {
@@ -197,7 +140,7 @@ function Button(props) {
197
140
  subscription.unsubscribe();
198
141
  });
199
142
  }
200
- return withScopedCSS(exportedId$k, () => {
143
+ return withScopedCSS(css$j, () => {
201
144
  return (jsxs("button", Object.assign({ type: "button" }, props, { class: [
202
145
  'btn',
203
146
  {
@@ -209,10 +152,10 @@ function Button(props) {
209
152
  });
210
153
  }
211
154
 
212
- var exportedId$j = "vf-ac7e8d";
155
+ var css$i = undefined;
213
156
 
214
157
  function ComponentToolbar(props) {
215
- return withScopedCSS(exportedId$j, () => {
158
+ return withScopedCSS(css$i, () => {
216
159
  return (jsx("div", { class: "component-toolbar", style: props.style, children: jsx("div", { class: [
217
160
  'toolbar',
218
161
  {
@@ -222,15 +165,15 @@ function ComponentToolbar(props) {
222
165
  });
223
166
  }
224
167
 
225
- var exportedId$i = "vf-ede279";
168
+ var css$h = undefined;
226
169
 
227
170
  function Divider() {
228
- return withScopedCSS(exportedId$i, () => {
171
+ return withScopedCSS(css$h, () => {
229
172
  return jsx("div", { class: "divider" });
230
173
  });
231
174
  }
232
175
 
233
- var exportedId$h = "vf-4c1803";
176
+ var style = undefined;
234
177
 
235
178
  function DragResize(props) {
236
179
  const isShow = createSignal(false);
@@ -338,16 +281,16 @@ function DragResize(props) {
338
281
  unUp.unsubscribe();
339
282
  });
340
283
  }
341
- return withScopedCSS(exportedId$h, () => {
284
+ return withScopedCSS(style, () => {
342
285
  return (jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsx("div", { class: "container", ref: ref, children: props.children }), jsxs("div", { class: ['resize-tool', {
343
286
  active: isShow()
344
287
  }], children: [jsxs("div", { class: "mask", ref: mask, children: [component.state.width, "*", component.state.height] }), jsxs("div", { class: "btn-group", ref: btnGroup, onMousedown: drag, children: [jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" })] })] })] }));
345
288
  });
346
289
  }
347
290
 
348
- var exportedId$g = "vf-a99c5e";
291
+ var css$g = undefined;
349
292
 
350
- var exportedId$f = "vf-4f8cfb";
293
+ var css$f = undefined;
351
294
 
352
295
  const DropdownMenuPortal = withAnnotation({
353
296
  providers: [
@@ -430,7 +373,7 @@ const DropdownMenuPortal = withAnnotation({
430
373
  dropdownContextService.canHide = true;
431
374
  dropdownContextService.hide();
432
375
  }
433
- return createPortal(withScopedCSS(exportedId$f, () => {
376
+ return createPortal(withScopedCSS(css$f, () => {
434
377
  return (jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
435
378
  width: props.width
436
379
  }, class: "dropdown-menu", children: jsx("div", { class: "dropdown-menu-content", children: props.children }) }));
@@ -454,6 +397,8 @@ const Dropdown = withAnnotation({
454
397
  const dropdownRef = createRef();
455
398
  onMounted(() => {
456
399
  const sub = dropdownContextService.onOpenStateChange.subscribe(b => {
400
+ var _a;
401
+ (_a = props.onExpendStateChange) === null || _a === void 0 ? void 0 : _a.call(props, b);
457
402
  isShow.set(b);
458
403
  });
459
404
  return () => sub.unsubscribe();
@@ -491,7 +436,7 @@ const Dropdown = withAnnotation({
491
436
  dropdownContextService.open();
492
437
  }
493
438
  },
494
- $render: withScopedCSS(exportedId$g, () => {
439
+ $render: withScopedCSS(css$g, () => {
495
440
  return (jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsx(DropdownMenuPortal, { width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
496
441
  props.menu.map(menu => {
497
442
  return (jsx("div", { class: "dropdown-menu-item", onClick: () => {
@@ -507,7 +452,7 @@ const Dropdown = withAnnotation({
507
452
  };
508
453
  });
509
454
 
510
- var exportedId$e = "vf-64f71d";
455
+ var css$e = undefined;
511
456
 
512
457
  function MenuItem(props) {
513
458
  const dropdownContextService = inject(DropdownContextService, InjectFlags.Optional, null);
@@ -527,7 +472,7 @@ function MenuItem(props) {
527
472
  }
528
473
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
529
474
  }
530
- return withScopedCSS(exportedId$e, () => {
475
+ return withScopedCSS(css$e, () => {
531
476
  return (jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxs("div", { children: [props.icon && jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), props.arrow ?
532
477
  jsx("div", { class: "arrow", children: jsx("span", { class: "xnote-icon-arrow-right" }) }) :
533
478
  jsx("div", { class: [
@@ -537,11 +482,11 @@ function MenuItem(props) {
537
482
  });
538
483
  }
539
484
 
540
- var exportedId$d = "vf-a23c47";
485
+ var css$d = undefined;
541
486
 
542
487
  function Popup(props) {
543
488
  const host = inject(VIEW_CONTAINER);
544
- return createPortal(withScopedCSS(exportedId$d, () => {
489
+ return createPortal(withScopedCSS(css$d, () => {
545
490
  return (jsx("div", { class: "popup", style: {
546
491
  left: props.left + 'px',
547
492
  top: props.top + 'px'
@@ -549,24 +494,19 @@ function Popup(props) {
549
494
  }), host);
550
495
  }
551
496
 
552
- var exportedId$c = "vf-216815";
497
+ var css$c = undefined;
553
498
 
554
499
  function ToolbarItem(props) {
555
- return withScopedCSS(exportedId$c, () => {
500
+ return withScopedCSS(css$c, () => {
556
501
  return (jsx("div", { class: "toolbar-item", children: props.children }));
557
502
  });
558
503
  }
559
504
 
560
- var exportedId$b = "vf-2a8a65";
505
+ var css$b = undefined;
561
506
 
562
507
  let RefreshService = class RefreshService {
563
508
  constructor() {
564
- Object.defineProperty(this, "onRefresh", {
565
- enumerable: true,
566
- configurable: true,
567
- writable: true,
568
- value: new Subject()
569
- });
509
+ this.onRefresh = new Subject();
570
510
  }
571
511
  };
572
512
  RefreshService = __decorate([
@@ -648,18 +588,8 @@ class ParagraphComponent extends Component {
648
588
  });
649
589
  }
650
590
  }
651
- Object.defineProperty(ParagraphComponent, "componentName", {
652
- enumerable: true,
653
- configurable: true,
654
- writable: true,
655
- value: 'ParagraphComponent'
656
- });
657
- Object.defineProperty(ParagraphComponent, "type", {
658
- enumerable: true,
659
- configurable: true,
660
- writable: true,
661
- value: ContentType.BlockComponent
662
- });
591
+ ParagraphComponent.componentName = 'ParagraphComponent';
592
+ ParagraphComponent.type = ContentType.BlockComponent;
663
593
  function ParagraphView(props) {
664
594
  const adapter = inject(DomAdapter);
665
595
  const readonly = useReadonly();
@@ -672,14 +602,14 @@ function ParagraphView(props) {
672
602
  }
673
603
  const paragraphComponentLoader = {
674
604
  match(element) {
675
- return element.dataset.compoment === ParagraphComponent.name || element.tagName === 'P';
605
+ return element.dataset.compoment === ParagraphComponent.name || /P|H[1-6]/.test(element.tagName);
676
606
  },
677
607
  read(element, textbus, slotParser) {
678
608
  const delta = slotParser(new Slot([
679
609
  ContentType.Text,
680
610
  ContentType.InlineComponent,
681
611
  ContentType.BlockComponent
682
- ]), element.tagName === 'P' ? element : element.children[0]).toDelta();
612
+ ]), /P|H[1-6]/.test(element.tagName) ? element : element.children[0]).toDelta();
683
613
  const results = deltaToBlock(delta, textbus);
684
614
  if (results.length === 1) {
685
615
  return results[0];
@@ -821,42 +751,27 @@ function createCodeSlot() {
821
751
  class SourceCodeComponent extends Component {
822
752
  constructor() {
823
753
  super(...arguments);
824
- Object.defineProperty(this, "focus", {
825
- enumerable: true,
826
- configurable: true,
827
- writable: true,
828
- value: new BehaviorSubject(false)
829
- });
830
- Object.defineProperty(this, "cancelEmphasize", {
831
- enumerable: true,
832
- configurable: true,
833
- writable: true,
834
- value: () => {
835
- const selection = this.textbus.get(Selection);
836
- const slots = this.state.slots;
837
- const { startSlot, endSlot } = selection;
838
- let startIndex = slots.findIndex(i => i.slot === startSlot);
839
- const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
840
- for (; startIndex < endIndex; startIndex++) {
841
- slots[startIndex].emphasize = false;
842
- }
754
+ this.focus = new BehaviorSubject(false);
755
+ this.cancelEmphasize = () => {
756
+ const selection = this.textbus.get(Selection);
757
+ const slots = this.state.slots;
758
+ const { startSlot, endSlot } = selection;
759
+ let startIndex = slots.findIndex(i => i.slot === startSlot);
760
+ const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
761
+ for (; startIndex < endIndex; startIndex++) {
762
+ slots[startIndex].emphasize = false;
843
763
  }
844
- });
845
- Object.defineProperty(this, "emphasize", {
846
- enumerable: true,
847
- configurable: true,
848
- writable: true,
849
- value: () => {
850
- const selection = this.textbus.get(Selection);
851
- const slots = this.state.slots;
852
- const { startSlot, endSlot } = selection;
853
- let startIndex = slots.findIndex(i => i.slot === startSlot);
854
- const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
855
- for (; startIndex < endIndex; startIndex++) {
856
- slots[startIndex].emphasize = true;
857
- }
764
+ };
765
+ this.emphasize = () => {
766
+ const selection = this.textbus.get(Selection);
767
+ const slots = this.state.slots;
768
+ const { startSlot, endSlot } = selection;
769
+ let startIndex = slots.findIndex(i => i.slot === startSlot);
770
+ const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
771
+ for (; startIndex < endIndex; startIndex++) {
772
+ slots[startIndex].emphasize = true;
858
773
  }
859
- });
774
+ };
860
775
  }
861
776
  static fromJSON(textbus, json) {
862
777
  const registry = textbus.get(Registry);
@@ -1027,68 +942,62 @@ class SourceCodeComponent extends Component {
1027
942
  }
1028
943
  });
1029
944
  }
945
+ removeSlot(slot) {
946
+ const slots = this.state.slots;
947
+ const index = slots.findIndex(i => i.slot === slot);
948
+ if (index > -1) {
949
+ slots.splice(index, 1);
950
+ return true;
951
+ }
952
+ return false;
953
+ }
1030
954
  }
1031
- Object.defineProperty(SourceCodeComponent, "type", {
1032
- enumerable: true,
1033
- configurable: true,
1034
- writable: true,
1035
- value: ContentType.BlockComponent
1036
- });
1037
- Object.defineProperty(SourceCodeComponent, "componentName", {
1038
- enumerable: true,
1039
- configurable: true,
1040
- writable: true,
1041
- value: 'SourceCodeComponent'
1042
- });
1043
- Object.defineProperty(SourceCodeComponent, "zenCoding", {
1044
- enumerable: true,
1045
- configurable: true,
1046
- writable: true,
1047
- value: {
1048
- key: 'Enter',
1049
- match(c) {
1050
- const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
1051
- const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
1052
- return reg.test(c);
1053
- },
1054
- createState(content) {
1055
- const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
1056
- for (const item of languageList) {
1057
- const reg = new RegExp(`^${matchString}$`, 'i');
1058
- if (reg.test(item.label || item.value)) {
1059
- return {
1060
- lang: item.value,
1061
- theme: '',
1062
- lineNumber: true,
1063
- slots: [createCodeSlot()]
1064
- };
1065
- }
1066
- }
1067
- if (/^js$/i.test(matchString)) {
1068
- return {
1069
- lang: 'JavaScript',
1070
- theme: '',
1071
- lineNumber: true,
1072
- slots: [createCodeSlot()]
1073
- };
1074
- }
1075
- if (/^ts$/i.test(matchString)) {
955
+ SourceCodeComponent.type = ContentType.BlockComponent;
956
+ SourceCodeComponent.componentName = 'SourceCodeComponent';
957
+ SourceCodeComponent.zenCoding = {
958
+ key: 'Enter',
959
+ match(c) {
960
+ const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
961
+ const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
962
+ return reg.test(c);
963
+ },
964
+ createState(content) {
965
+ const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
966
+ for (const item of languageList) {
967
+ const reg = new RegExp(`^${matchString}$`, 'i');
968
+ if (reg.test(item.label || item.value)) {
1076
969
  return {
1077
- lang: 'TypeScript',
970
+ lang: item.value,
1078
971
  theme: '',
1079
972
  lineNumber: true,
1080
973
  slots: [createCodeSlot()]
1081
974
  };
1082
975
  }
976
+ }
977
+ if (/^js$/i.test(matchString)) {
978
+ return {
979
+ lang: 'JavaScript',
980
+ theme: '',
981
+ lineNumber: true,
982
+ slots: [createCodeSlot()]
983
+ };
984
+ }
985
+ if (/^ts$/i.test(matchString)) {
1083
986
  return {
1084
- lang: '',
987
+ lang: 'TypeScript',
1085
988
  theme: '',
1086
989
  lineNumber: true,
1087
990
  slots: [createCodeSlot()]
1088
991
  };
1089
992
  }
993
+ return {
994
+ lang: '',
995
+ theme: '',
996
+ lineNumber: true,
997
+ slots: [createCodeSlot()]
998
+ };
1090
999
  }
1091
- });
1000
+ };
1092
1001
  function SourceCodeView(props) {
1093
1002
  const adapter = inject(DomAdapter);
1094
1003
  const isFocus = createSignal(false);
@@ -1176,11 +1085,11 @@ function SourceCodeView(props) {
1176
1085
  return textNode;
1177
1086
  });
1178
1087
  }
1179
- return (jsxs("pre", { ref: props.rootRef, class: {
1088
+ return (jsxs("div", { ref: props.rootRef, class: {
1180
1089
  'xnote-source-code': true,
1181
1090
  'xnote-source-code-line-number': state.lineNumber,
1182
1091
  [state.theme || 'github']: true
1183
- }, lang: state.lang, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [!readonly() || !output() && jsxs(ComponentToolbar, { visible: isFocus(), children: [jsx(ToolbarItem, { children: jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
1092
+ }, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [(!readonly() && !output()) && jsxs(ComponentToolbar, { visible: isFocus(), children: [jsx(ToolbarItem, { children: jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
1184
1093
  return {
1185
1094
  label: jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
1186
1095
  value: item.value
@@ -1227,10 +1136,10 @@ function SourceCodeView(props) {
1227
1136
  children.push(br);
1228
1137
  }
1229
1138
  }
1230
- return createVNode('div', {
1139
+ return createVNode('pre', {
1231
1140
  class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
1232
1141
  }, [
1233
- createVNode('div', { class: 'xnote-source-code-line-content' }, children)
1142
+ createVNode('span', { class: 'xnote-source-code-line-content' }, children)
1234
1143
  ]);
1235
1144
  }, readonly());
1236
1145
  }) }), jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
@@ -1238,12 +1147,13 @@ function SourceCodeView(props) {
1238
1147
  }
1239
1148
  const sourceCodeComponentLoader = {
1240
1149
  match(element) {
1241
- return element.tagName === 'PRE';
1150
+ return element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName ||
1151
+ element.tagName === 'PRE';
1242
1152
  },
1243
1153
  read(el, textbus) {
1244
- const lines = el.querySelectorAll('.xnote-source-code-line');
1245
1154
  let slots = [];
1246
- if (lines.length) {
1155
+ if (el.tagName === 'DIV') {
1156
+ const lines = el.querySelectorAll('.xnote-source-code-line');
1247
1157
  slots = Array.from(lines).map(i => {
1248
1158
  const code = i.innerText.replace(/[\s\n]+$/, '');
1249
1159
  const item = createCodeSlot();
@@ -1264,9 +1174,10 @@ const sourceCodeComponentLoader = {
1264
1174
  });
1265
1175
  }
1266
1176
  return new SourceCodeComponent(textbus, {
1267
- lang: el.getAttribute('lang') || '',
1268
- theme: el.getAttribute('theme') || '',
1269
- lineNumber: !el.classList.contains('xnote-source-code-hide-line-number'),
1177
+ lang: el.dataset.lang || '',
1178
+ theme: el.dataset.theme || '',
1179
+ lineNumber: !!el.dataset.lineNumber || true,
1180
+ autoBreak: !!el.dataset.autoBreak || true,
1270
1181
  slots
1271
1182
  });
1272
1183
  },
@@ -1420,7 +1331,7 @@ function AttrTool(props) {
1420
1331
  break;
1421
1332
  }
1422
1333
  }
1423
- return withScopedCSS(exportedId$b, () => {
1334
+ return withScopedCSS(css$b, () => {
1424
1335
  const states = checkStates();
1425
1336
  return (jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
1426
1337
  {
@@ -1559,24 +1470,9 @@ class TableComponent extends Component {
1559
1470
  })
1560
1471
  }) {
1561
1472
  super(textbus, state);
1562
- Object.defineProperty(this, "selection", {
1563
- enumerable: true,
1564
- configurable: true,
1565
- writable: true,
1566
- value: this.textbus.get(Selection)
1567
- });
1568
- Object.defineProperty(this, "focus", {
1569
- enumerable: true,
1570
- configurable: true,
1571
- writable: true,
1572
- value: new Subject()
1573
- });
1574
- Object.defineProperty(this, "tableSelection", {
1575
- enumerable: true,
1576
- configurable: true,
1577
- writable: true,
1578
- value: createSignal(null)
1579
- });
1473
+ this.selection = this.textbus.get(Selection);
1474
+ this.focus = new Subject();
1475
+ this.tableSelection = createSignal(null);
1580
1476
  }
1581
1477
  setup() {
1582
1478
  onFocusIn(() => {
@@ -1701,18 +1597,8 @@ class TableComponent extends Component {
1701
1597
  });
1702
1598
  }
1703
1599
  }
1704
- Object.defineProperty(TableComponent, "componentName", {
1705
- enumerable: true,
1706
- configurable: true,
1707
- writable: true,
1708
- value: 'TableComponent'
1709
- });
1710
- Object.defineProperty(TableComponent, "type", {
1711
- enumerable: true,
1712
- configurable: true,
1713
- writable: true,
1714
- value: ContentType.BlockComponent
1715
- });
1600
+ TableComponent.componentName = 'TableComponent';
1601
+ TableComponent.type = ContentType.BlockComponent;
1716
1602
 
1717
1603
  const strikeThroughFormatter = new Formatter('strike', {
1718
1604
  columned: true,
@@ -1817,37 +1703,22 @@ class TodolistComponent extends Component {
1817
1703
  });
1818
1704
  }
1819
1705
  }
1820
- Object.defineProperty(TodolistComponent, "type", {
1821
- enumerable: true,
1822
- configurable: true,
1823
- writable: true,
1824
- value: ContentType.BlockComponent
1825
- });
1826
- Object.defineProperty(TodolistComponent, "componentName", {
1827
- enumerable: true,
1828
- configurable: true,
1829
- writable: true,
1830
- value: 'TodoListComponent'
1831
- });
1832
- Object.defineProperty(TodolistComponent, "zenCoding", {
1833
- enumerable: true,
1834
- configurable: true,
1835
- writable: true,
1836
- value: {
1837
- match: /^\[(x|\s)?\]$/,
1838
- key: ' ',
1839
- createState(content) {
1840
- const isChecked = content.charAt(1) === 'x';
1841
- return {
1842
- checked: isChecked,
1843
- slot: new Slot([
1844
- ContentType.InlineComponent,
1845
- ContentType.Text
1846
- ])
1847
- };
1848
- }
1706
+ TodolistComponent.type = ContentType.BlockComponent;
1707
+ TodolistComponent.componentName = 'TodoListComponent';
1708
+ TodolistComponent.zenCoding = {
1709
+ match: /^\[(x|\s)?\]$/,
1710
+ key: ' ',
1711
+ createState(content) {
1712
+ const isChecked = content.charAt(1) === 'x';
1713
+ return {
1714
+ checked: isChecked,
1715
+ slot: new Slot([
1716
+ ContentType.InlineComponent,
1717
+ ContentType.Text
1718
+ ])
1719
+ };
1849
1720
  }
1850
- });
1721
+ };
1851
1722
  function TodolistView(props) {
1852
1723
  const adapter = inject(DomAdapter);
1853
1724
  const component = props.component;
@@ -1921,36 +1792,21 @@ class BlockquoteComponent extends Component {
1921
1792
  useBlockContent(this.state.slot);
1922
1793
  }
1923
1794
  }
1924
- Object.defineProperty(BlockquoteComponent, "type", {
1925
- enumerable: true,
1926
- configurable: true,
1927
- writable: true,
1928
- value: ContentType.BlockComponent
1929
- });
1930
- Object.defineProperty(BlockquoteComponent, "componentName", {
1931
- enumerable: true,
1932
- configurable: true,
1933
- writable: true,
1934
- value: 'BlockquoteComponent'
1935
- });
1936
- Object.defineProperty(BlockquoteComponent, "zenCoding", {
1937
- enumerable: true,
1938
- configurable: true,
1939
- writable: true,
1940
- value: {
1941
- key: ' ',
1942
- match: /^>$/,
1943
- createState() {
1944
- return {
1945
- slot: new Slot([
1946
- ContentType.Text,
1947
- ContentType.InlineComponent,
1948
- ContentType.BlockComponent
1949
- ])
1950
- };
1951
- }
1795
+ BlockquoteComponent.type = ContentType.BlockComponent;
1796
+ BlockquoteComponent.componentName = 'BlockquoteComponent';
1797
+ BlockquoteComponent.zenCoding = {
1798
+ key: ' ',
1799
+ match: /^>$/,
1800
+ createState() {
1801
+ return {
1802
+ slot: new Slot([
1803
+ ContentType.Text,
1804
+ ContentType.InlineComponent,
1805
+ ContentType.BlockComponent
1806
+ ])
1807
+ };
1952
1808
  }
1953
- });
1809
+ };
1954
1810
  function BlockquoteView(props) {
1955
1811
  const adapter = inject(DomAdapter);
1956
1812
  const readonly = useReadonly();
@@ -2067,37 +1923,22 @@ class ListComponent extends Component {
2067
1923
  });
2068
1924
  }
2069
1925
  }
2070
- Object.defineProperty(ListComponent, "componentName", {
2071
- enumerable: true,
2072
- configurable: true,
2073
- writable: true,
2074
- value: 'ListComponent'
2075
- });
2076
- Object.defineProperty(ListComponent, "type", {
2077
- enumerable: true,
2078
- configurable: true,
2079
- writable: true,
2080
- value: ContentType.BlockComponent
2081
- });
2082
- Object.defineProperty(ListComponent, "zenCoding", {
2083
- enumerable: true,
2084
- configurable: true,
2085
- writable: true,
2086
- value: {
2087
- key: ' ',
2088
- match: /^([1-9]\.|[+*])$/,
2089
- createState(content) {
2090
- return {
2091
- type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
2092
- reorder: true,
2093
- slot: new Slot([
2094
- ContentType.InlineComponent,
2095
- ContentType.Text
2096
- ])
2097
- };
2098
- }
1926
+ ListComponent.componentName = 'ListComponent';
1927
+ ListComponent.type = ContentType.BlockComponent;
1928
+ ListComponent.zenCoding = {
1929
+ key: ' ',
1930
+ match: /^([1-9]\.|[+*])$/,
1931
+ createState(content) {
1932
+ return {
1933
+ type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
1934
+ reorder: true,
1935
+ slot: new Slot([
1936
+ ContentType.InlineComponent,
1937
+ ContentType.Text
1938
+ ])
1939
+ };
2099
1940
  }
2100
- });
1941
+ };
2101
1942
  const step = 26;
2102
1943
  const chars = Array.from({ length: step }).map((_, index) => String.fromCharCode(96 + index + 1));
2103
1944
  function numberToLetter(num) {
@@ -2187,7 +2028,7 @@ function ListComponentView(props) {
2187
2028
  }, children: jsxs("li", { style: {
2188
2029
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2189
2030
  textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
2190
- }, children: [jsx("div", { class: "xnote-list-type", children: component.state.type === 'UnorderedList' || readonly() || output() ?
2031
+ }, children: [jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2191
2032
  jsx("span", { class: "xnote-order-btn", children: icon })
2192
2033
  :
2193
2034
  jsx(Dropdown, { menu: jsxs(Fragment, { children: [jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), adapter.slotRender(component.state.slot, children => {
@@ -2310,24 +2151,9 @@ class HighlightBoxComponent extends Component {
2310
2151
  useBlockContent(this.state.slot);
2311
2152
  }
2312
2153
  }
2313
- Object.defineProperty(HighlightBoxComponent, "defaultTypes", {
2314
- enumerable: true,
2315
- configurable: true,
2316
- writable: true,
2317
- value: ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗']
2318
- });
2319
- Object.defineProperty(HighlightBoxComponent, "componentName", {
2320
- enumerable: true,
2321
- configurable: true,
2322
- writable: true,
2323
- value: 'HighlightBoxComponent'
2324
- });
2325
- Object.defineProperty(HighlightBoxComponent, "type", {
2326
- enumerable: true,
2327
- configurable: true,
2328
- writable: true,
2329
- value: ContentType.BlockComponent
2330
- });
2154
+ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
2155
+ HighlightBoxComponent.componentName = 'HighlightBoxComponent';
2156
+ HighlightBoxComponent.type = ContentType.BlockComponent;
2331
2157
  function HighlightBoxView(props) {
2332
2158
  const adapter = inject(DomAdapter);
2333
2159
  const readonly = useReadonly();
@@ -2599,7 +2425,7 @@ function useBlockTransform() {
2599
2425
  function BlockTool() {
2600
2426
  const checkStates = useActiveBlock();
2601
2427
  const transform = useBlockTransform();
2602
- return withScopedCSS(exportedId$b, () => {
2428
+ return withScopedCSS(css$b, () => {
2603
2429
  const states = checkStates();
2604
2430
  const types = [
2605
2431
  [states.paragraph, 'xnote-icon-pilcrow'],
@@ -3030,7 +2856,7 @@ function CodeTool() {
3030
2856
  };
3031
2857
  }
3032
2858
 
3033
- var exportedId$a = "vf-1fbbdf";
2859
+ var css$a = undefined;
3034
2860
 
3035
2861
  function ColorTool(props) {
3036
2862
  const query = inject(Query);
@@ -3078,7 +2904,7 @@ function ColorTool(props) {
3078
2904
  '#90a0e5',
3079
2905
  '#c596e0',
3080
2906
  ];
3081
- return withScopedCSS(exportedId$a, () => {
2907
+ return withScopedCSS(css$a, () => {
3082
2908
  const vm = viewModel();
3083
2909
  return (jsx(Dropdown, { style: props.style, abreast: props.abreast, trigger: 'hover', menu: jsxs("div", { children: [jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxs("div", { class: "text-colors", children: [jsx("div", { class: {
3084
2910
  active: textColor() === ''
@@ -3286,7 +3112,7 @@ function ItalicTool() {
3286
3112
  };
3287
3113
  }
3288
3114
 
3289
- var exportedId$9 = "vf-269a0b";
3115
+ var css$9 = undefined;
3290
3116
 
3291
3117
  function LinkTool(props) {
3292
3118
  const selectionBridge = inject(SelectionBridge);
@@ -3317,7 +3143,7 @@ function LinkTool(props) {
3317
3143
  onUnmounted(() => {
3318
3144
  sub.unsubscribe();
3319
3145
  });
3320
- return withScopedCSS(exportedId$9, () => {
3146
+ return withScopedCSS(css$9, () => {
3321
3147
  const containerRect = container.getBoundingClientRect();
3322
3148
  const rect = isShow() ? selectionBridge.getRect({
3323
3149
  slot: selection.focusSlot,
@@ -3386,7 +3212,7 @@ function UnderlineTool() {
3386
3212
  };
3387
3213
  }
3388
3214
 
3389
- var exportedId$8 = "vf-cf8e1c";
3215
+ var css$8 = undefined;
3390
3216
 
3391
3217
  function InsertTool(props) {
3392
3218
  const commander = inject(Commander);
@@ -3398,6 +3224,14 @@ function InsertTool(props) {
3398
3224
  if (!component) {
3399
3225
  return;
3400
3226
  }
3227
+ function insertComponent(comp) {
3228
+ if (props.replace) {
3229
+ commander.replaceComponent(component, comp);
3230
+ }
3231
+ else {
3232
+ commander.insertAfter(comp, component);
3233
+ }
3234
+ }
3401
3235
  switch (type) {
3402
3236
  case 'h1':
3403
3237
  case 'h2':
@@ -3412,12 +3246,12 @@ function InsertTool(props) {
3412
3246
  ContentType.Text
3413
3247
  ]);
3414
3248
  if (/h[1-6]/.test(type)) {
3415
- slot.setAttribute(headingAttr, +type.substring(1));
3249
+ slot.setAttribute(headingAttr, type);
3416
3250
  }
3417
3251
  const p = new ParagraphComponent(textbus, {
3418
3252
  slot
3419
3253
  });
3420
- commander.insertAfter(p, component);
3254
+ insertComponent(p);
3421
3255
  selection.setPosition(slot, 0);
3422
3256
  }
3423
3257
  break;
@@ -3433,7 +3267,7 @@ function InsertTool(props) {
3433
3267
  reorder: true,
3434
3268
  type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
3435
3269
  });
3436
- commander.insertAfter(list, component);
3270
+ insertComponent(list);
3437
3271
  selection.setPosition(slot, 0);
3438
3272
  }
3439
3273
  break;
@@ -3450,14 +3284,14 @@ function InsertTool(props) {
3450
3284
  emphasize: false
3451
3285
  }]
3452
3286
  });
3453
- commander.insertAfter(comp, component);
3287
+ insertComponent(comp);
3454
3288
  selection.setPosition(slot, 0);
3455
3289
  }
3456
3290
  break;
3457
3291
  case 'table':
3458
3292
  {
3459
3293
  const table = new TableComponent(textbus);
3460
- commander.insertAfter(table, component);
3294
+ insertComponent(table);
3461
3295
  selection.setPosition(table.state.rows[0].cells[0].slot, 0);
3462
3296
  }
3463
3297
  break;
@@ -3471,7 +3305,7 @@ function InsertTool(props) {
3471
3305
  slot,
3472
3306
  checked: false
3473
3307
  });
3474
- commander.insertAfter(comp, component);
3308
+ insertComponent(comp);
3475
3309
  selection.setPosition(slot, 0);
3476
3310
  }
3477
3311
  break;
@@ -3484,18 +3318,18 @@ function InsertTool(props) {
3484
3318
  const p = new ParagraphComponent(textbus);
3485
3319
  const comp = new HighlightBoxComponent(textbus);
3486
3320
  comp.state.slot.insert(p);
3487
- commander.insertAfter(comp, component);
3321
+ insertComponent(comp);
3488
3322
  selection.setPosition(p.state.slot, 0);
3489
3323
  }
3490
3324
  break;
3491
3325
  }
3492
3326
  }
3493
- return withScopedCSS(exportedId$8, () => {
3327
+ return withScopedCSS(css$8, () => {
3494
3328
  return jsxs(Fragment, { children: [jsxs("div", { class: "btn-group", children: [jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsx("span", { class: "xnote-icon-pilcrow" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsx("span", { class: "xnote-icon-heading-h1" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsx("span", { class: "xnote-icon-heading-h2" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsx("span", { class: "xnote-icon-heading-h3" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsx("span", { class: "xnote-icon-heading-h4" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsx("span", { class: "xnote-icon-heading-h5" }) }), jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsx("span", { class: "xnote-icon-heading-h6" }) }), jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsx("span", { class: "xnote-icon-list-numbered" }) }), jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsx("span", { class: "xnote-icon-list" }) }), jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsx("span", { class: "xnote-icon-source-code" }) })] }), jsx(Divider, {}), jsx(MenuItem, { onClick: () => insert('table'), icon: jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsx(MenuItem, { onClick: () => insert('image'), icon: jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsx(MenuItem, { onClick: () => insert('video'), icon: jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsx("span", { class: "xnote-icon-warning" }), children: "\u9AD8\u4EAE\u5757" })] });
3495
3329
  });
3496
3330
  }
3497
3331
 
3498
- var exportedId$7 = "vf-b05292";
3332
+ var css$7 = undefined;
3499
3333
 
3500
3334
  const LeftToolbar = withAnnotation({
3501
3335
  providers: [RefreshService]
@@ -3523,11 +3357,12 @@ const LeftToolbar = withAnnotation({
3523
3357
  top: 0,
3524
3358
  display: false
3525
3359
  });
3360
+ let isIgnoreMove = false;
3526
3361
  onMounted(() => {
3527
3362
  const rootComponent = rootComponentRef.component;
3528
3363
  const docContentContainer = adapter.getNativeNodeBySlot(rootComponent.state.content);
3529
3364
  const sub = fromEvent(docContentContainer, 'mousemove').pipe(filter(() => {
3530
- return selection.isCollapsed;
3365
+ return !isIgnoreMove;
3531
3366
  }), map(ev => {
3532
3367
  let currentNode = ev.target;
3533
3368
  while (currentNode) {
@@ -3654,7 +3489,10 @@ const LeftToolbar = withAnnotation({
3654
3489
  }
3655
3490
  }
3656
3491
  const isEmptyBlock = createSignal(true);
3657
- return withScopedCSS(exportedId$7, () => {
3492
+ function changeIgnoreMove(b) {
3493
+ isIgnoreMove = b;
3494
+ }
3495
+ return withScopedCSS(css$7, () => {
3658
3496
  const position = positionSignal();
3659
3497
  const slot = activeSlot();
3660
3498
  let activeNode = jsx("span", { class: "xnote-icon-pilcrow" });
@@ -3686,11 +3524,14 @@ const LeftToolbar = withAnnotation({
3686
3524
  left: position.left + 'px',
3687
3525
  top: position.top + 'px',
3688
3526
  display: position.display && selection.isCollapsed ? 'block' : 'none'
3689
- }, children: jsx(Dropdown, { abreast: true, style: {
3527
+ }, children: jsx(Dropdown, { onExpendStateChange: changeIgnoreMove, abreast: true, style: {
3690
3528
  position: 'absolute',
3691
3529
  right: 0,
3692
3530
  top: 0
3693
- }, menu: jsxs(Fragment, { children: [jsxs("div", { class: "btn-group", children: [jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsx("span", { class: "xnote-icon-pilcrow" }) }), jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsx("span", { class: "xnote-icon-heading-h1" }) }), jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsx("span", { class: "xnote-icon-heading-h2" }) }), jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsx("span", { class: "xnote-icon-heading-h3" }) }), jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsx("span", { class: "xnote-icon-heading-h4" }) }), jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsx("span", { class: "xnote-icon-list-numbered" }) }), jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsx("span", { class: "xnote-icon-list" }) }), jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsx("span", { class: "xnote-icon-quotes-right" }) }), jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsx("span", { class: "xnote-icon-source-code" }) })] }), jsx(Divider, {}), jsx(AttrTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, queryBefore: queryBefore, queryAfter: queryAfter, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, queryBefore: queryBefore, queryAfter: queryAfter, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsx(Divider, {}), jsx(MenuItem, { onClick: copy, icon: jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsx(MenuItem, { onClick: remove, icon: jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsx(MenuItem, { onClick: cut, icon: jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsx(Divider, {}), jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsx(InsertTool, { slot: activeSlot() }), children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
3531
+ }, menu: isEmptyBlock() ?
3532
+ jsx(InsertTool, { replace: true, slot: activeSlot() })
3533
+ :
3534
+ jsxs(Fragment, { children: [jsxs("div", { class: "btn-group", children: [jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsx("span", { class: "xnote-icon-pilcrow" }) }), jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsx("span", { class: "xnote-icon-heading-h1" }) }), jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsx("span", { class: "xnote-icon-heading-h2" }) }), jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsx("span", { class: "xnote-icon-heading-h3" }) }), jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsx("span", { class: "xnote-icon-heading-h4" }) }), jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsx("span", { class: "xnote-icon-list-numbered" }) }), jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsx("span", { class: "xnote-icon-list" }) }), jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsx("span", { class: "xnote-icon-quotes-right" }) }), jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsx("span", { class: "xnote-icon-source-code" }) })] }), jsx(Divider, {}), jsx(AttrTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, queryBefore: queryBefore, queryAfter: queryAfter, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, queryBefore: queryBefore, queryAfter: queryAfter, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsx(Divider, {}), jsx(MenuItem, { onClick: copy, icon: jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsx(MenuItem, { onClick: remove, icon: jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsx(MenuItem, { onClick: cut, icon: jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsx(Divider, {}), jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsx(InsertTool, { slot: activeSlot() }), children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
3694
3535
  jsx("span", { children: jsx("i", { class: "xnote-icon-plus" }) })
3695
3536
  :
3696
3537
  jsxs("span", { children: [activeNode, jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
@@ -3699,12 +3540,7 @@ const LeftToolbar = withAnnotation({
3699
3540
 
3700
3541
  class LeftToolbarPlugin {
3701
3542
  constructor() {
3702
- Object.defineProperty(this, "app", {
3703
- enumerable: true,
3704
- configurable: true,
3705
- writable: true,
3706
- value: null
3707
- });
3543
+ this.app = null;
3708
3544
  }
3709
3545
  setup(injector) {
3710
3546
  const App = function () {
@@ -3719,7 +3555,7 @@ class LeftToolbarPlugin {
3719
3555
  nativeRenderer: new DomRenderer(),
3720
3556
  autoUpdate: true
3721
3557
  });
3722
- const viewDocument = injector.get(VIEW_DOCUMENT);
3558
+ const viewDocument = injector.get(VIEW_CONTAINER);
3723
3559
  const host = document.createElement('div');
3724
3560
  viewDocument.appendChild(host);
3725
3561
  this.app.mount(host);
@@ -3730,16 +3566,11 @@ class LeftToolbarPlugin {
3730
3566
  }
3731
3567
  }
3732
3568
 
3733
- var exportedId$6 = "vf-fee98b";
3569
+ var css$6 = undefined;
3734
3570
 
3735
3571
  let EditorService = class EditorService {
3736
3572
  constructor() {
3737
- Object.defineProperty(this, "hideInlineToolbar", {
3738
- enumerable: true,
3739
- configurable: true,
3740
- writable: true,
3741
- value: false
3742
- });
3573
+ this.hideInlineToolbar = false;
3743
3574
  }
3744
3575
  };
3745
3576
  EditorService = __decorate([
@@ -3752,7 +3583,7 @@ const Toolbar = withAnnotation({
3752
3583
  providers: [RefreshService]
3753
3584
  }, function Toolbar() {
3754
3585
  const selection = inject(Selection);
3755
- const viewDocument = inject(VIEW_DOCUMENT);
3586
+ const viewDocument = inject(VIEW_CONTAINER);
3756
3587
  const bridge = inject(SelectionBridge);
3757
3588
  const textbus = inject(Textbus);
3758
3589
  const editorService = inject(EditorService);
@@ -3845,7 +3676,7 @@ const Toolbar = withAnnotation({
3845
3676
  mousedownSubscription.unsubscribe();
3846
3677
  mouseupSubscription.unsubscribe();
3847
3678
  });
3848
- return withScopedCSS(exportedId$6, () => {
3679
+ return withScopedCSS(css$6, () => {
3849
3680
  const p = viewPosition();
3850
3681
  return (jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
3851
3682
  left: p.left + 'px',
@@ -3860,12 +3691,7 @@ const Toolbar = withAnnotation({
3860
3691
 
3861
3692
  class ToolbarPlugin {
3862
3693
  constructor() {
3863
- Object.defineProperty(this, "app", {
3864
- enumerable: true,
3865
- configurable: true,
3866
- writable: true,
3867
- value: null
3868
- });
3694
+ this.app = null;
3869
3695
  }
3870
3696
  setup(injector) {
3871
3697
  const App = function () {
@@ -3890,30 +3716,10 @@ class ToolbarPlugin {
3890
3716
 
3891
3717
  class Matcher {
3892
3718
  constructor(target, rule) {
3893
- Object.defineProperty(this, "target", {
3894
- enumerable: true,
3895
- configurable: true,
3896
- writable: true,
3897
- value: target
3898
- });
3899
- Object.defineProperty(this, "rule", {
3900
- enumerable: true,
3901
- configurable: true,
3902
- writable: true,
3903
- value: rule
3904
- });
3905
- Object.defineProperty(this, "validators", {
3906
- enumerable: true,
3907
- configurable: true,
3908
- writable: true,
3909
- value: []
3910
- });
3911
- Object.defineProperty(this, "excludeValidators", {
3912
- enumerable: true,
3913
- configurable: true,
3914
- writable: true,
3915
- value: []
3916
- });
3719
+ this.target = target;
3720
+ this.rule = rule;
3721
+ this.validators = [];
3722
+ this.excludeValidators = [];
3917
3723
  if (rule.tags) {
3918
3724
  this.validators.push(this.makeTagsMatcher(rule.tags));
3919
3725
  }
@@ -4010,18 +3816,8 @@ class ImageComponent extends Component {
4010
3816
  return new ImageComponent(textbus, Object.assign({}, json));
4011
3817
  }
4012
3818
  }
4013
- Object.defineProperty(ImageComponent, "type", {
4014
- enumerable: true,
4015
- configurable: true,
4016
- writable: true,
4017
- value: ContentType.InlineComponent
4018
- });
4019
- Object.defineProperty(ImageComponent, "componentName", {
4020
- enumerable: true,
4021
- configurable: true,
4022
- writable: true,
4023
- value: 'ImageComponent'
4024
- });
3819
+ ImageComponent.type = ContentType.InlineComponent;
3820
+ ImageComponent.componentName = 'ImageComponent';
4025
3821
  function ImageView(props) {
4026
3822
  const { name, state } = props.component;
4027
3823
  const imageRef = createRef();
@@ -4055,12 +3851,7 @@ const imageComponentLoader = {
4055
3851
  class RootComponent extends Component {
4056
3852
  constructor() {
4057
3853
  super(...arguments);
4058
- Object.defineProperty(this, "onCompositionStart", {
4059
- enumerable: true,
4060
- configurable: true,
4061
- writable: true,
4062
- value: new Subject()
4063
- });
3854
+ this.onCompositionStart = new Subject();
4064
3855
  }
4065
3856
  static fromJSON(textbus, json) {
4066
3857
  const heading = textbus.get(Registry).createSlot(json.heading);
@@ -4103,18 +3894,8 @@ class RootComponent extends Component {
4103
3894
  content.insert(new ParagraphComponent(this.textbus));
4104
3895
  }
4105
3896
  }
4106
- Object.defineProperty(RootComponent, "componentName", {
4107
- enumerable: true,
4108
- configurable: true,
4109
- writable: true,
4110
- value: 'RootComponent'
4111
- });
4112
- Object.defineProperty(RootComponent, "type", {
4113
- enumerable: true,
4114
- configurable: true,
4115
- writable: true,
4116
- value: ContentType.BlockComponent
4117
- });
3897
+ RootComponent.componentName = 'RootComponent';
3898
+ RootComponent.type = ContentType.BlockComponent;
4118
3899
  function RootView(props) {
4119
3900
  const adapter = inject(DomAdapter);
4120
3901
  const { heading, content } = props.component.state;
@@ -4172,40 +3953,15 @@ const rootComponentLoader = {
4172
3953
  }
4173
3954
  };
4174
3955
 
4175
- var exportedId$5 = "vf-681de2";
3956
+ var css$5 = undefined;
4176
3957
 
4177
3958
  let TableService = class TableService {
4178
3959
  constructor() {
4179
- Object.defineProperty(this, "onInsertRowBefore", {
4180
- enumerable: true,
4181
- configurable: true,
4182
- writable: true,
4183
- value: new Subject()
4184
- });
4185
- Object.defineProperty(this, "onInsertColumnBefore", {
4186
- enumerable: true,
4187
- configurable: true,
4188
- writable: true,
4189
- value: new Subject()
4190
- });
4191
- Object.defineProperty(this, "onSelectColumns", {
4192
- enumerable: true,
4193
- configurable: true,
4194
- writable: true,
4195
- value: new Subject()
4196
- });
4197
- Object.defineProperty(this, "onSelectRows", {
4198
- enumerable: true,
4199
- configurable: true,
4200
- writable: true,
4201
- value: new Subject()
4202
- });
4203
- Object.defineProperty(this, "onScroll", {
4204
- enumerable: true,
4205
- configurable: true,
4206
- writable: true,
4207
- value: new Subject()
4208
- });
3960
+ this.onInsertRowBefore = new Subject();
3961
+ this.onInsertColumnBefore = new Subject();
3962
+ this.onSelectColumns = new Subject();
3963
+ this.onSelectRows = new Subject();
3964
+ this.onScroll = new Subject();
4209
3965
  }
4210
3966
  };
4211
3967
  TableService = __decorate([
@@ -4284,12 +4040,12 @@ function ResizeColumn(props) {
4284
4040
  });
4285
4041
  return () => sub.unsubscribe();
4286
4042
  });
4287
- return withScopedCSS(exportedId$5, () => {
4043
+ return withScopedCSS(css$5, () => {
4288
4044
  return jsx("div", { ref: dragLineRef, class: ['drag-line'] });
4289
4045
  });
4290
4046
  }
4291
4047
 
4292
- var exportedId$4 = "vf-5bce97";
4048
+ var css$4 = undefined;
4293
4049
 
4294
4050
  function TopBar(props) {
4295
4051
  const editorService = inject(EditorService);
@@ -4357,7 +4113,7 @@ function TopBar(props) {
4357
4113
  s.unsubscribe();
4358
4114
  });
4359
4115
  const deleteIndex = createSignal(null);
4360
- return withScopedCSS(exportedId$4, () => {
4116
+ return withScopedCSS(css$4, () => {
4361
4117
  const { state, tableSelection } = props.component;
4362
4118
  const position = tableSelection();
4363
4119
  return (jsx("div", { class: ['top-bar', {
@@ -4410,7 +4166,7 @@ function TopBar(props) {
4410
4166
  });
4411
4167
  }
4412
4168
 
4413
- var exportedId$3 = "vf-b1149b";
4169
+ var css$3 = undefined;
4414
4170
 
4415
4171
  function Scroll(props) {
4416
4172
  const scrollRef = createRef();
@@ -4442,7 +4198,7 @@ function Scroll(props) {
4442
4198
  draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
4443
4199
  });
4444
4200
  });
4445
- return withScopedCSS(exportedId$3, () => {
4201
+ return withScopedCSS(css$3, () => {
4446
4202
  return jsx("div", { ref: [scrollRef, props.scrollRef], class: ['scroll-container', {
4447
4203
  'left-end': showShadow().leftEnd,
4448
4204
  'right-end': showShadow().rightEnd,
@@ -4454,7 +4210,7 @@ function Scroll(props) {
4454
4210
  });
4455
4211
  }
4456
4212
 
4457
- var exportedId$2 = "vf-ef93c0";
4213
+ var css$2 = undefined;
4458
4214
 
4459
4215
  function LeftBar(props) {
4460
4216
  const editorService = inject(EditorService);
@@ -4528,7 +4284,7 @@ function LeftBar(props) {
4528
4284
  textbus.focus();
4529
4285
  });
4530
4286
  }
4531
- return withScopedCSS(exportedId$2, () => {
4287
+ return withScopedCSS(css$2, () => {
4532
4288
  const { state, tableSelection } = props.component;
4533
4289
  const position = tableSelection();
4534
4290
  return (jsxs("div", { class: ['left-bar', { active: props.isFocus() }], children: [jsx("div", { class: "insert-bar", children: jsx("table", { ref: insertBarRef, children: jsx("tbody", { children: state.rows.map((_, index) => {
@@ -4576,7 +4332,7 @@ function LeftBar(props) {
4576
4332
  });
4577
4333
  }
4578
4334
 
4579
- var exportedId$1 = "vf-d4c4a9";
4335
+ var css$1 = undefined;
4580
4336
 
4581
4337
  function sum(numbers) {
4582
4338
  return numbers.reduce((a, b) => a + b, 0);
@@ -4609,7 +4365,7 @@ function ResizeRow(props) {
4609
4365
  });
4610
4366
  return () => sub.unsubscribe();
4611
4367
  });
4612
- return withScopedCSS(exportedId$1, () => {
4368
+ return withScopedCSS(css$1, () => {
4613
4369
  return jsx("div", { ref: dragLineRef, style: {
4614
4370
  display: styles().visible ? 'block' : 'none',
4615
4371
  top: styles().top + 'px',
@@ -4618,7 +4374,7 @@ function ResizeRow(props) {
4618
4374
  });
4619
4375
  }
4620
4376
 
4621
- var exportedId = "vf-e16878";
4377
+ var css = undefined;
4622
4378
 
4623
4379
  function SelectionMask(props) {
4624
4380
  const [styles, updateStyles] = useProduce({
@@ -4671,7 +4427,7 @@ function SelectionMask(props) {
4671
4427
  onUnmounted(() => {
4672
4428
  s.unsubscribe();
4673
4429
  });
4674
- return withScopedCSS(exportedId, () => {
4430
+ return withScopedCSS(css, () => {
4675
4431
  const style = styles();
4676
4432
  return (jsx("div", { class: "mask", style: {
4677
4433
  display: style.visible ? 'block' : 'none',
@@ -4977,18 +4733,8 @@ class VideoComponent extends Component {
4977
4733
  //
4978
4734
  }
4979
4735
  }
4980
- Object.defineProperty(VideoComponent, "type", {
4981
- enumerable: true,
4982
- configurable: true,
4983
- writable: true,
4984
- value: ContentType.InlineComponent
4985
- });
4986
- Object.defineProperty(VideoComponent, "componentName", {
4987
- enumerable: true,
4988
- configurable: true,
4989
- writable: true,
4990
- value: 'VideoComponent'
4991
- });
4736
+ VideoComponent.type = ContentType.InlineComponent;
4737
+ VideoComponent.componentName = 'VideoComponent';
4992
4738
  function VideoView(props) {
4993
4739
  const { name, state } = props.component;
4994
4740
  const videoRef = createRef();
@@ -5019,9 +4765,9 @@ const videoComponentLoader = {
5019
4765
  }
5020
4766
  };
5021
4767
 
5022
- function createXNote(host, config = {}) {
5023
- return __awaiter(this, void 0, void 0, function* () {
5024
- const adapter = new Adapter({
4768
+ function createXNote(host_1) {
4769
+ return __awaiter(this, arguments, void 0, function* (host, config = {}) {
4770
+ const adapter = new ViewflyAdapter({
5025
4771
  [ParagraphComponent.componentName]: ParagraphView,
5026
4772
  [RootComponent.componentName]: RootView,
5027
4773
  [BlockquoteComponent.componentName]: BlockquoteView,
@@ -5032,8 +4778,8 @@ function createXNote(host, config = {}) {
5032
4778
  [ListComponent.componentName]: ListComponentView,
5033
4779
  [ImageComponent.componentName]: ImageView,
5034
4780
  [VideoComponent.componentName]: VideoView
5035
- }, (host, root) => {
5036
- const appInjector = new ReflectiveInjector(textbus, [{
4781
+ }, (host, root, injector) => {
4782
+ const appInjector = new ReflectiveInjector(injector, [{
5037
4783
  provide: OutputInjectionToken,
5038
4784
  useValue: false
5039
4785
  }]);
@@ -5044,6 +4790,35 @@ function createXNote(host, config = {}) {
5044
4790
  app.destroy();
5045
4791
  };
5046
4792
  });
4793
+ const vDomAdapter = new ViewflyVDomAdapter({
4794
+ [ParagraphComponent.componentName]: ParagraphView,
4795
+ [RootComponent.componentName]: RootView,
4796
+ [BlockquoteComponent.componentName]: BlockquoteView,
4797
+ [TodolistComponent.componentName]: TodolistView,
4798
+ [SourceCodeComponent.componentName]: SourceCodeView,
4799
+ [TableComponent.componentName]: TableComponentView,
4800
+ [HighlightBoxComponent.componentName]: HighlightBoxView,
4801
+ [ListComponent.componentName]: ListComponentView,
4802
+ [ImageComponent.componentName]: ImageView,
4803
+ [VideoComponent.componentName]: VideoView
4804
+ }, (host, root, injector) => {
4805
+ const appInjector = new ReflectiveInjector(injector, [{
4806
+ provide: OutputInjectionToken,
4807
+ useValue: true
4808
+ }, {
4809
+ provide: DomAdapter,
4810
+ useFactory() {
4811
+ return vDomAdapter;
4812
+ }
4813
+ }]);
4814
+ const app = createApp(root, {
4815
+ context: appInjector,
4816
+ nativeRenderer: new HTMLRenderer()
4817
+ }).mount(host);
4818
+ return () => {
4819
+ app.destroy();
4820
+ };
4821
+ });
5047
4822
  const browserModule = new BrowserModule({
5048
4823
  renderTo() {
5049
4824
  return host;
@@ -5083,6 +4858,7 @@ function createXNote(host, config = {}) {
5083
4858
  modules.push(new CollaborateModule(config.collaborateConfig));
5084
4859
  }
5085
4860
  const textbus = new Textbus({
4861
+ additionalAdapters: [vDomAdapter],
5086
4862
  zenCoding: true,
5087
4863
  readonly: config.readonly,
5088
4864
  imports: modules,
@@ -5147,8 +4923,13 @@ function createXNote(host, config = {}) {
5147
4923
  });
5148
4924
  }
5149
4925
  yield textbus.render(rootComp);
5150
- // console.log(rootComp)
5151
- return textbus;
4926
+ const translator = new OutputTranslator();
4927
+ return {
4928
+ textbus,
4929
+ getHTML() {
4930
+ return translator.transform(vDomAdapter.host);
4931
+ }
4932
+ };
5152
4933
  });
5153
4934
  }
5154
4935