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