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

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.
Files changed (36) hide show
  1. package/README.md +26 -1
  2. package/bundles/components/_api.d.ts +2 -0
  3. package/bundles/components/dropdown/dropdown-menu.d.ts +3 -0
  4. package/bundles/components/dropdown/dropdown.d.ts +4 -1
  5. package/bundles/components/keymap/keymap.d.ts +5 -0
  6. package/bundles/components/menu-heading/menu-heading.d.ts +2 -0
  7. package/bundles/components/menu-item/menu-item.d.ts +3 -2
  8. package/bundles/editor.d.ts +14 -4
  9. package/bundles/fonts/textbus.svg +3 -32
  10. package/bundles/fonts/textbus.ttf +0 -0
  11. package/bundles/fonts/textbus.woff +0 -0
  12. package/bundles/index.css +2 -2
  13. package/bundles/index.esm.css +2 -2
  14. package/bundles/index.esm.js +2008 -1425
  15. package/bundles/index.js +2018 -1420
  16. package/bundles/interfaces.d.ts +3 -0
  17. package/bundles/plugins/_api.d.ts +1 -0
  18. package/bundles/plugins/_common/attr.tool.d.ts +2 -2
  19. package/bundles/plugins/_common/color.tool.d.ts +2 -2
  20. package/bundles/plugins/left-toolbar/insert-tool.d.ts +5 -2
  21. package/bundles/plugins/link-jump/link-jump.d.ts +4 -0
  22. package/bundles/services/editor.service.d.ts +4 -0
  23. package/bundles/textbus/components/_api.d.ts +3 -0
  24. package/bundles/textbus/components/at/at-component.view.d.ts +6 -0
  25. package/bundles/textbus/components/at/at.component.d.ts +34 -0
  26. package/bundles/textbus/components/blockqoute/blockquote.component.d.ts +3 -1
  27. package/bundles/textbus/components/katex/katex-editor.d.ts +7 -0
  28. package/bundles/textbus/components/katex/katex.component.d.ts +15 -0
  29. package/bundles/textbus/components/list/list.component.d.ts +2 -0
  30. package/bundles/textbus/components/root/root.component.d.ts +0 -1
  31. package/bundles/textbus/components/source-code/source-code.component.d.ts +2 -1
  32. package/bundles/textbus/components/table/components/resize-column.d.ts +2 -1
  33. package/bundles/textbus/components/table/components/top-bar.d.ts +1 -0
  34. package/bundles/textbus/components/table/table-selection-awareness-delegate.d.ts +15 -0
  35. package/bundles/textbus/components/table/table.component.d.ts +0 -1
  36. package/package.json +36 -12
package/bundles/index.js CHANGED
@@ -8,10 +8,12 @@ var platformBrowser = require('@textbus/platform-browser');
8
8
  var platformBrowser$1 = require('@viewfly/platform-browser');
9
9
  var hooks = require('@viewfly/hooks');
10
10
  var highlightjs = require('highlight.js');
11
+ var Katex = require('katex');
11
12
  var adapterViewfly = require('@textbus/adapter-viewfly');
13
+ var color = require('@tanbo/color');
12
14
  var collaborate = require('@textbus/collaborate');
13
15
 
14
- var exportedId$k = "vf-69b4db";
16
+ var scopedId$n = "vf-d94b56";
15
17
 
16
18
  /******************************************************************************
17
19
  Copyright (c) Microsoft Corporation.
@@ -41,16 +43,6 @@ function __metadata(metadataKey, metadataValue) {
41
43
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
42
44
  }
43
45
 
44
- function __awaiter(thisArg, _arguments, P, generator) {
45
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
- return new (P || (P = Promise))(function (resolve, reject) {
47
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
- step((generator = generator.apply(thisArg, _arguments || [])).next());
51
- });
52
- }
53
-
54
46
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
55
47
  var e = new Error(message);
56
48
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -58,18 +50,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
58
50
 
59
51
  exports.DropdownService = class DropdownService {
60
52
  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
- });
53
+ this.siblingOpenEvent = new core$1.Subject();
73
54
  this.onSiblingOpen = this.siblingOpenEvent.asObservable();
74
55
  }
75
56
  notify(id) {
@@ -87,60 +68,14 @@ var DropdownContextService_1;
87
68
  let i = 0;
88
69
  exports.DropdownContextService = DropdownContextService_1 = class DropdownContextService {
89
70
  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
- });
71
+ this.dropdownService = dropdownService;
72
+ this.injector = injector;
73
+ this.id = i;
74
+ this.isOpen = false;
75
+ this.canHide = true;
76
+ this.openStateChangeEvent = new core$1.Subject();
77
+ this.timer = null;
78
+ this.parentDropdownContextService = this.injector.get(DropdownContextService_1, null, core.InjectFlags.SkipSelf);
144
79
  this.onOpenStateChange = this.openStateChangeEvent.asObservable();
145
80
  dropdownService.onSiblingOpen.subscribe(id => {
146
81
  if (id === this.id) {
@@ -189,7 +124,7 @@ exports.DropdownContextService = DropdownContextService_1 = __decorate([
189
124
  ], exports.DropdownContextService);
190
125
 
191
126
  function Button(props) {
192
- const dropdownContextService = core.inject(exports.DropdownContextService, core.InjectFlags.Optional, null);
127
+ const dropdownContextService = core.inject(exports.DropdownContextService, null);
193
128
  const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
194
129
  if (dropdownContextService) {
195
130
  const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
@@ -199,7 +134,7 @@ function Button(props) {
199
134
  subscription.unsubscribe();
200
135
  });
201
136
  }
202
- return scopedCss.withScopedCSS(exportedId$k, () => {
137
+ return scopedCss.withScopedCSS(scopedId$n, () => {
203
138
  return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
204
139
  'btn',
205
140
  {
@@ -211,10 +146,10 @@ function Button(props) {
211
146
  });
212
147
  }
213
148
 
214
- var exportedId$j = "vf-ac7e8d";
149
+ var scopedId$m = "vf-ac7e8d";
215
150
 
216
151
  function ComponentToolbar(props) {
217
- return scopedCss.withScopedCSS(exportedId$j, () => {
152
+ return scopedCss.withScopedCSS(scopedId$m, () => {
218
153
  return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
219
154
  'toolbar',
220
155
  {
@@ -224,15 +159,15 @@ function ComponentToolbar(props) {
224
159
  });
225
160
  }
226
161
 
227
- var exportedId$i = "vf-ede279";
162
+ var scopedId$l = "vf-ede279";
228
163
 
229
164
  function Divider() {
230
- return scopedCss.withScopedCSS(exportedId$i, () => {
165
+ return scopedCss.withScopedCSS(scopedId$l, () => {
231
166
  return jsxRuntime.jsx("div", { class: "divider" });
232
167
  });
233
168
  }
234
169
 
235
- var exportedId$h = "vf-4c1803";
170
+ var scopedId$k = "vf-4c1803";
236
171
 
237
172
  function DragResize(props) {
238
173
  const isShow = core.createSignal(false);
@@ -340,16 +275,16 @@ function DragResize(props) {
340
275
  unUp.unsubscribe();
341
276
  });
342
277
  }
343
- return scopedCss.withScopedCSS(exportedId$h, () => {
278
+ return scopedCss.withScopedCSS(scopedId$k, () => {
344
279
  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
280
  active: isShow()
346
281
  }], 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
282
  });
348
283
  }
349
284
 
350
- var exportedId$g = "vf-a99c5e";
285
+ var scopedId$j = "vf-a99c5e";
351
286
 
352
- var exportedId$f = "vf-4f8cfb";
287
+ var scopedId$i = "vf-8a05e9";
353
288
 
354
289
  const DropdownMenuPortal = core.withAnnotation({
355
290
  providers: [
@@ -357,11 +292,14 @@ const DropdownMenuPortal = core.withAnnotation({
357
292
  ]
358
293
  }, function DropdownMenuPortal(props) {
359
294
  const dropdownContextService = core.inject(exports.DropdownContextService);
295
+ const container = core.inject(platformBrowser.VIEW_CONTAINER);
360
296
  const menuRef = core.createRef();
361
297
  let timer = null;
362
298
  const delay = 10;
363
- core.onMounted(() => {
299
+ function update() {
364
300
  const menuElement = menuRef.current;
301
+ menuElement.style.height = 'auto';
302
+ const containerRect = container.getBoundingClientRect();
365
303
  if (props.abreast) {
366
304
  const btnEle = props.triggerRef.current;
367
305
  const screenHeight = document.documentElement.clientHeight;
@@ -376,19 +314,19 @@ const DropdownMenuPortal = core.withAnnotation({
376
314
  else if (offsetTop + maxHeight > screenHeight - 10) {
377
315
  offsetTop = screenHeight - 10 - maxHeight;
378
316
  }
379
- menuElement.style.top = offsetTop + 'px';
317
+ menuElement.style.top = offsetTop - containerRect.top + 'px';
380
318
  const triggerRect = props.triggerRef.current.getBoundingClientRect();
381
319
  const leftDistance = triggerRect.left;
382
320
  const isToLeft = leftDistance >= menuElement.offsetWidth + 20;
383
- if (isToLeft) {
384
- menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 + 'px';
321
+ if (isToLeft && props.toLeft) {
322
+ menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 - containerRect.left + 'px';
385
323
  timer = setTimeout(() => {
386
324
  menuElement.style.transform = 'translateX(10px)';
387
325
  menuElement.style.opacity = '1';
388
326
  }, delay);
389
327
  }
390
328
  else {
391
- menuElement.style.left = triggerRect.right + 20 + 'px';
329
+ menuElement.style.left = triggerRect.right + 20 - containerRect.left + 'px';
392
330
  timer = setTimeout(() => {
393
331
  menuElement.style.transform = 'translateX(-10px)';
394
332
  menuElement.style.opacity = '1';
@@ -400,12 +338,12 @@ const DropdownMenuPortal = core.withAnnotation({
400
338
  const documentClientHeight = document.documentElement.clientHeight;
401
339
  const bottomDistance = documentClientHeight - triggerRect.bottom;
402
340
  const isToTop = bottomDistance < 200 && triggerRect.top > bottomDistance;
403
- menuElement.style.left = triggerRect.left + 'px';
341
+ menuElement.style.left = triggerRect.left - containerRect.left + 'px';
404
342
  if (isToTop) {
405
343
  const maxHeight = Math.max(menuElement.scrollHeight, menuElement.offsetHeight);
406
- const height = Math.min(triggerRect.top - 20, maxHeight);
344
+ const height = Math.min(triggerRect.top - 20, maxHeight, 400);
407
345
  menuElement.style.height = height + 'px';
408
- menuElement.style.top = triggerRect.top - 20 - height + 'px';
346
+ menuElement.style.top = triggerRect.top - 20 - height - containerRect.top + 'px';
409
347
  timer = setTimeout(() => {
410
348
  menuElement.style.transform = 'translateY(10px)';
411
349
  menuElement.style.opacity = '1';
@@ -413,30 +351,41 @@ const DropdownMenuPortal = core.withAnnotation({
413
351
  }
414
352
  else {
415
353
  menuElement.style.height = Math.min(bottomDistance - 20, menuElement.scrollHeight) + 'px';
416
- menuElement.style.top = triggerRect.bottom + 20 + 'px';
354
+ menuElement.style.top = triggerRect.bottom + 20 - containerRect.top + 'px';
417
355
  timer = setTimeout(() => {
418
356
  menuElement.style.transform = 'translateY(-10px)';
419
357
  menuElement.style.opacity = '1';
420
358
  }, delay);
421
359
  }
422
360
  }
361
+ }
362
+ core.onUpdated(() => {
363
+ update();
423
364
  });
424
365
  core.onUnmounted(() => {
425
366
  clearTimeout(timer);
426
367
  });
427
368
  function onEnter() {
369
+ if (props.noTrigger) {
370
+ return;
371
+ }
428
372
  dropdownContextService.canHide = false;
429
373
  dropdownContextService.open();
430
374
  }
431
375
  function onLeave() {
376
+ if (props.noTrigger) {
377
+ return;
378
+ }
432
379
  dropdownContextService.canHide = true;
433
380
  dropdownContextService.hide();
434
381
  }
435
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(exportedId$f, () => {
382
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$i, () => {
436
383
  return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
437
384
  width: props.width
438
- }, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", children: props.children }) }));
439
- }), document.body);
385
+ }, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
386
+ padding: props.padding
387
+ }, children: props.children }) }));
388
+ }), container);
440
389
  });
441
390
 
442
391
  const Dropdown = core.withAnnotation({
@@ -456,12 +405,17 @@ const Dropdown = core.withAnnotation({
456
405
  const dropdownRef = core.createRef();
457
406
  core.onMounted(() => {
458
407
  const sub = dropdownContextService.onOpenStateChange.subscribe(b => {
408
+ var _a;
409
+ (_a = props.onExpendStateChange) === null || _a === void 0 ? void 0 : _a.call(props, b);
459
410
  isShow.set(b);
460
411
  });
461
412
  return () => sub.unsubscribe();
462
413
  });
463
414
  const subscription = new core$1.Subscription();
464
415
  core.onMounted(() => {
416
+ if (props.trigger === 'none') {
417
+ return;
418
+ }
465
419
  if (props.trigger === 'click') {
466
420
  subscription.add(core$1.fromEvent(triggerRef.current, 'click').subscribe(toggle));
467
421
  return;
@@ -487,14 +441,14 @@ const Dropdown = core.withAnnotation({
487
441
  return {
488
442
  isShow(b) {
489
443
  if (b) {
490
- dropdownContextService.hide(false);
444
+ dropdownContextService.open();
491
445
  }
492
446
  else {
493
- dropdownContextService.open();
447
+ dropdownContextService.hide(false);
494
448
  }
495
449
  },
496
- $render: scopedCss.withScopedCSS(exportedId$g, () => {
497
- 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) ?
450
+ $render: scopedCss.withScopedCSS(scopedId$j, () => {
451
+ 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, { toLeft: props.toLeft, padding: props.padding, noTrigger: props.trigger === 'none', width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
498
452
  props.menu.map(menu => {
499
453
  return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
500
454
  var _a;
@@ -509,10 +463,54 @@ const Dropdown = core.withAnnotation({
509
463
  };
510
464
  });
511
465
 
512
- var exportedId$e = "vf-64f71d";
466
+ var scopedId$h = "vf-c32a7b";
467
+
468
+ function Keymap(props) {
469
+ const arr = [];
470
+ const keymap = props.keymap;
471
+ if (keymap.ctrlKey) {
472
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-command" }) : jsxRuntime.jsx("span", { children: "Ctrl" }));
473
+ }
474
+ if (keymap.shiftKey) {
475
+ if (arr.length) {
476
+ arr.push('+');
477
+ }
478
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-shift" }) : jsxRuntime.jsx("span", { children: "Shift" }));
479
+ }
480
+ if (keymap.altKey) {
481
+ if (arr.length) {
482
+ arr.push('+');
483
+ }
484
+ arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-opt" }) : jsxRuntime.jsx("span", { children: "Alt" }));
485
+ }
486
+ if (keymap.key) {
487
+ if (arr.length) {
488
+ arr.push('+');
489
+ }
490
+ if (Array.isArray(keymap.key)) {
491
+ arr.push(jsxRuntime.jsx("span", { children: keymap.key.join('/') }));
492
+ }
493
+ else {
494
+ arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
495
+ }
496
+ }
497
+ return scopedCss.withScopedCSS(scopedId$h, () => {
498
+ return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
499
+ });
500
+ }
501
+
502
+ var scopedId$g = "vf-acaa5f";
503
+
504
+ function MenuHeading(props) {
505
+ return scopedCss.withScopedCSS(scopedId$g, () => {
506
+ return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
507
+ });
508
+ }
509
+
510
+ var scopedId$f = "vf-c3b9dc";
513
511
 
514
512
  function MenuItem(props) {
515
- const dropdownContextService = core.inject(exports.DropdownContextService, core.InjectFlags.Optional, null);
513
+ const dropdownContextService = core.inject(exports.DropdownContextService, null);
516
514
  const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
517
515
  if (dropdownContextService) {
518
516
  const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
@@ -529,8 +527,8 @@ function MenuItem(props) {
529
527
  }
530
528
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
531
529
  }
532
- return scopedCss.withScopedCSS(exportedId$e, () => {
533
- 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 ?
530
+ return scopedCss.withScopedCSS(scopedId$f, () => {
531
+ return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { class: "menu-item-content", children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), jsxRuntime.jsx("div", { children: props.desc })] }), props.arrow ?
534
532
  jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
535
533
  jsxRuntime.jsx("div", { class: [
536
534
  'menu-check',
@@ -539,11 +537,11 @@ function MenuItem(props) {
539
537
  });
540
538
  }
541
539
 
542
- var exportedId$d = "vf-a23c47";
540
+ var scopedId$e = "vf-a23c47";
543
541
 
544
542
  function Popup(props) {
545
543
  const host = core.inject(platformBrowser.VIEW_CONTAINER);
546
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(exportedId$d, () => {
544
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$e, () => {
547
545
  return (jsxRuntime.jsx("div", { class: "popup", style: {
548
546
  left: props.left + 'px',
549
547
  top: props.top + 'px'
@@ -551,24 +549,19 @@ function Popup(props) {
551
549
  }), host);
552
550
  }
553
551
 
554
- var exportedId$c = "vf-216815";
552
+ var scopedId$d = "vf-216815";
555
553
 
556
554
  function ToolbarItem(props) {
557
- return scopedCss.withScopedCSS(exportedId$c, () => {
555
+ return scopedCss.withScopedCSS(scopedId$d, () => {
558
556
  return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
559
557
  });
560
558
  }
561
559
 
562
- var exportedId$b = "vf-2a8a65";
560
+ var scopedId$c = "vf-2a8a65";
563
561
 
564
562
  exports.RefreshService = class RefreshService {
565
563
  constructor() {
566
- Object.defineProperty(this, "onRefresh", {
567
- enumerable: true,
568
- configurable: true,
569
- writable: true,
570
- value: new core$1.Subject()
571
- });
564
+ this.onRefresh = new core$1.Subject();
572
565
  }
573
566
  };
574
567
  exports.RefreshService = __decorate([
@@ -620,120 +613,409 @@ function useReadonly() {
620
613
  return is;
621
614
  }
622
615
 
623
- class ParagraphComponent extends core$1.Component {
616
+ const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
617
+
618
+ function useOutput() {
619
+ return core.createSignal(core.inject(OutputInjectionToken));
620
+ }
621
+
622
+ const headingAttr = new core$1.Attribute('Heading', {
623
+ render(node, formatValue) {
624
+ node.classes.add('xnote-' + formatValue);
625
+ }
626
+ });
627
+ const headingAttrLoader = {
628
+ match(element) {
629
+ return /H[1-6]/.test(element.tagName) || /(^|\s)xnote-h[1-6](\s|$)/.test(element.className);
630
+ },
631
+ read(element) {
632
+ if (/H[1-6]/.test(element.tagName)) {
633
+ return {
634
+ attribute: headingAttr,
635
+ value: element.tagName.toLowerCase()
636
+ };
637
+ }
638
+ return {
639
+ attribute: headingAttr,
640
+ value: element.className.substring(6)
641
+ };
642
+ }
643
+ };
644
+ function registerHeadingShortcut(textbus) {
645
+ const keyboard = textbus.get(core$1.Keyboard);
646
+ const commander = textbus.get(core$1.Commander);
647
+ const selection = textbus.get(core$1.Selection);
648
+ keyboard.addShortcut({
649
+ keymap: {
650
+ key: '0123456'.split(''),
651
+ ctrlKey: true
652
+ },
653
+ action(key) {
654
+ if (key === '0') {
655
+ commander.unApplyAttribute(headingAttr);
656
+ return;
657
+ }
658
+ commander.applyAttribute(headingAttr, 'h' + key);
659
+ }
660
+ });
661
+ keyboard.addZenCodingInterceptor({
662
+ match(content) {
663
+ return /^#{1,6}$/.test(content);
664
+ },
665
+ try(key) {
666
+ return key === ' ';
667
+ },
668
+ action(content) {
669
+ if (selection.commonAncestorComponent instanceof SourceCodeComponent) {
670
+ return false;
671
+ }
672
+ const commonAncestorSlot = selection.commonAncestorSlot;
673
+ commonAncestorSlot.cut();
674
+ commander.applyAttribute(headingAttr, 'h' + content.length);
675
+ selection.setPosition(commonAncestorSlot, 0);
676
+ return true;
677
+ }
678
+ });
679
+ }
680
+
681
+ function useBlockContent(slot) {
682
+ const textbus = core$1.useContext();
683
+ const selection = textbus.get(core$1.Selection);
684
+ core$1.onBreak(ev => {
685
+ if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
686
+ const p = new ParagraphComponent(textbus);
687
+ ev.target.insert(p);
688
+ selection.setPosition(p.state.slot, 0);
689
+ ev.preventDefault();
690
+ }
691
+ });
692
+ core$1.onContentInsert(ev => {
693
+ if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
694
+ (typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
695
+ const p = new ParagraphComponent(textbus);
696
+ const childSlot = p.state.slot;
697
+ childSlot.insert(ev.data.content);
698
+ ev.target.insert(p);
699
+ selection.setPosition(childSlot, childSlot.index);
700
+ ev.preventDefault();
701
+ }
702
+ });
703
+ }
704
+
705
+ class BlockquoteComponent extends core$1.Component {
624
706
  static fromJSON(textbus, json) {
625
707
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
626
- return new ParagraphComponent(textbus, {
708
+ return new BlockquoteComponent(textbus, {
627
709
  slot
628
710
  });
629
711
  }
630
712
  constructor(textbus, state = {
631
713
  slot: new core$1.Slot([
632
- core$1.ContentType.InlineComponent,
633
- core$1.ContentType.Text
714
+ core$1.ContentType.BlockComponent
634
715
  ])
635
716
  }) {
636
717
  super(textbus, state);
637
718
  }
638
719
  setup() {
639
- const injector = core$1.useContext();
640
- const commander = injector.get(core$1.Commander);
641
- const selection = injector.get(core$1.Selection);
642
- core$1.onBreak(ev => {
643
- const afterSlot = ev.target.cut(ev.data.index);
644
- const nextParagraph = new ParagraphComponent(injector, {
645
- slot: afterSlot
646
- });
647
- commander.insertAfter(nextParagraph, this);
648
- selection.setPosition(afterSlot, 0);
649
- ev.preventDefault();
720
+ useBlockContent(this.state.slot);
721
+ }
722
+ }
723
+ BlockquoteComponent.type = core$1.ContentType.BlockComponent;
724
+ BlockquoteComponent.componentName = 'BlockquoteComponent';
725
+ BlockquoteComponent.zenCoding = {
726
+ key: ' ',
727
+ match(content, textbus) {
728
+ const selection = textbus.get(core$1.Selection);
729
+ if (selection.commonAncestorComponent instanceof ParagraphComponent) {
730
+ return /^>$/.test(content);
731
+ }
732
+ return false;
733
+ },
734
+ createState(_, textbus) {
735
+ const selection = textbus.get(core$1.Selection);
736
+ const commonAncestorSlot = selection.commonAncestorSlot;
737
+ const slot = new core$1.Slot([
738
+ core$1.ContentType.BlockComponent
739
+ ]);
740
+ if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
741
+ slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
742
+ }
743
+ return {
744
+ slot
745
+ };
746
+ }
747
+ };
748
+ function toBlockquote(textbus) {
749
+ const query = textbus.get(core$1.Query);
750
+ const commander = textbus.get(core$1.Commander);
751
+ const selection = textbus.get(core$1.Selection);
752
+ const state = query.queryComponent(BlockquoteComponent);
753
+ if (state.state === core$1.QueryStateType.Enabled) {
754
+ const current = state.value;
755
+ const parent = current.parent;
756
+ const index = parent.indexOf(current);
757
+ parent.retain(index);
758
+ commander.removeComponent(current);
759
+ current.__slots__.get(0).sliceContent().forEach(i => {
760
+ parent.insert(i);
650
761
  });
651
762
  }
763
+ else {
764
+ const block = new BlockquoteComponent(textbus);
765
+ const slot = block.state.slot;
766
+ if (selection.startSlot === selection.endSlot) {
767
+ const parentComponent = selection.startSlot.parent;
768
+ const parentSlot = parentComponent.parent;
769
+ const position = parentSlot.indexOf(parentComponent);
770
+ slot.insert(parentComponent);
771
+ parentSlot.retain(position);
772
+ parentSlot.insert(block);
773
+ }
774
+ else {
775
+ const commonAncestorSlot = selection.commonAncestorSlot;
776
+ const scope = selection.getCommonAncestorSlotScope();
777
+ commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
778
+ slot.insert(i);
779
+ });
780
+ commonAncestorSlot.retain(scope.startOffset);
781
+ commonAncestorSlot.insert(block);
782
+ }
783
+ }
652
784
  }
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
- });
665
- function ParagraphView(props) {
785
+ function registerBlockquoteShortcut(textbus) {
786
+ const keyboard = textbus.get(core$1.Keyboard);
787
+ keyboard.addShortcut({
788
+ keymap: {
789
+ ctrlKey: true,
790
+ key: '\''
791
+ },
792
+ action() {
793
+ toBlockquote(textbus);
794
+ }
795
+ });
796
+ }
797
+ function BlockquoteView(props) {
666
798
  const adapter = core.inject(platformBrowser.DomAdapter);
667
799
  const readonly = useReadonly();
800
+ const output = useOutput();
668
801
  return () => {
669
802
  const slot = props.component.state.slot;
670
- return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.name, children: adapter.slotRender(slot, children => {
671
- return (core$1.createVNode('p', null, children));
672
- }, readonly()) }));
803
+ return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
804
+ return core$1.createVNode('div', null, children);
805
+ }, readonly() || output()) }));
673
806
  };
674
807
  }
675
- const paragraphComponentLoader = {
676
- match(element) {
677
- return element.dataset.compoment === ParagraphComponent.name || element.tagName === 'P';
808
+ const blockquoteComponentLoader = {
809
+ match(element, returnableContentTypes) {
810
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
678
811
  },
679
812
  read(element, textbus, slotParser) {
680
813
  const delta = slotParser(new core$1.Slot([
681
- core$1.ContentType.Text,
814
+ core$1.ContentType.BlockComponent,
682
815
  core$1.ContentType.InlineComponent,
683
- core$1.ContentType.BlockComponent
684
- ]), element.tagName === 'P' ? element : element.children[0]).toDelta();
685
- const results = deltaToBlock(delta, textbus);
686
- if (results.length === 1) {
687
- return results[0];
688
- }
689
- const containerSlot = new core$1.Slot([
690
- core$1.ContentType.BlockComponent
816
+ core$1.ContentType.Text
817
+ ]), element).toDelta();
818
+ const slot = new core$1.Slot([
819
+ core$1.ContentType.BlockComponent,
691
820
  ]);
692
- results.forEach(item => {
693
- containerSlot.insert(item);
821
+ deltaToBlock(delta, textbus).forEach(i => {
822
+ slot.insert(i);
694
823
  });
695
- return containerSlot;
696
- }
824
+ return new BlockquoteComponent(textbus, {
825
+ slot
826
+ });
827
+ },
697
828
  };
698
- function deltaToBlock(delta, textbus) {
699
- const results = [];
700
- let slot = null;
701
- for (const item of delta) {
702
- if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
703
- if (!slot) {
704
- slot = new core$1.Slot([
705
- core$1.ContentType.InlineComponent,
706
- core$1.ContentType.Text
707
- ]);
708
- delta.attributes.forEach((value, key) => {
709
- slot.setAttribute(key, value);
710
- });
711
- results.push(new ParagraphComponent(textbus, {
712
- slot
713
- }));
714
- }
715
- slot.insert(item.insert, item.formats);
716
- }
717
- else {
718
- results.push(item.insert);
719
- slot = null;
720
- }
721
- }
722
- return results;
723
- }
724
-
725
- const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
726
-
727
- function useOutput() {
728
- return core.createSignal(core.inject(OutputInjectionToken));
729
- }
730
829
 
731
- const languageList = [{
732
- label: 'JavaScript',
733
- value: 'JavaScript',
734
- }, {
735
- label: 'HTML',
736
- value: 'HTML',
830
+ class HighlightBoxComponent extends core$1.Component {
831
+ static fromJSON(textbus, json) {
832
+ return new HighlightBoxComponent(textbus, {
833
+ type: json.type,
834
+ slot: textbus.get(core$1.Registry).createSlot(json.slot)
835
+ });
836
+ }
837
+ constructor(textbus, state = {
838
+ type: '',
839
+ slot: new core$1.Slot([
840
+ core$1.ContentType.BlockComponent,
841
+ ])
842
+ }) {
843
+ super(textbus, state);
844
+ }
845
+ setup() {
846
+ useBlockContent(this.state.slot);
847
+ }
848
+ }
849
+ HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
850
+ HighlightBoxComponent.componentName = 'HighlightBoxComponent';
851
+ HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
852
+ function HighlightBoxView(props) {
853
+ const adapter = core.inject(platformBrowser.DomAdapter);
854
+ const readonly = useReadonly();
855
+ const output = useOutput();
856
+ const emoji = [];
857
+ for (let i = 0x1F600; i <= 0x1F64F; i++) {
858
+ emoji.push(i);
859
+ }
860
+ const dropdownRef = core.createRef();
861
+ function setType(type) {
862
+ var _a;
863
+ (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
864
+ props.component.state.type = type;
865
+ }
866
+ return () => {
867
+ const { state, name } = props.component;
868
+ if (readonly() || output()) {
869
+ return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
870
+ return core$1.createVNode('div', {
871
+ class: 'xnote-highlight-box-content'
872
+ }, children);
873
+ }, readonly() || output())] }));
874
+ }
875
+ return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "282px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u5E38\u7528" }), HighlightBoxComponent.defaultTypes.map(icon => {
876
+ return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
877
+ }), jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
878
+ const icon = String.fromCodePoint(i);
879
+ return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
880
+ })] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
881
+ return core$1.createVNode('div', {
882
+ class: 'xnote-highlight-box-content'
883
+ }, children);
884
+ }, readonly() || output())] }));
885
+ };
886
+ }
887
+ const highlightBoxComponentLoader = {
888
+ match(element) {
889
+ return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
890
+ },
891
+ read(element, textbus, slotParser) {
892
+ const delta = slotParser(new core$1.Slot([
893
+ core$1.ContentType.BlockComponent,
894
+ core$1.ContentType.InlineComponent,
895
+ core$1.ContentType.Text
896
+ ]), element.querySelector('.xnote-highlight-box-content')).toDelta();
897
+ const slot = new core$1.Slot([
898
+ core$1.ContentType.BlockComponent,
899
+ ]);
900
+ deltaToBlock(delta, textbus).forEach(i => {
901
+ slot.insert(i);
902
+ });
903
+ return new HighlightBoxComponent(textbus, {
904
+ type: element.dataset.icon || '',
905
+ slot
906
+ });
907
+ }
908
+ };
909
+
910
+ class ParagraphComponent extends core$1.Component {
911
+ static fromJSON(textbus, json) {
912
+ const slot = textbus.get(core$1.Registry).createSlot(json.slot);
913
+ return new ParagraphComponent(textbus, {
914
+ slot
915
+ });
916
+ }
917
+ constructor(textbus, state = {
918
+ slot: new core$1.Slot([
919
+ core$1.ContentType.InlineComponent,
920
+ core$1.ContentType.Text
921
+ ])
922
+ }) {
923
+ super(textbus, state);
924
+ }
925
+ setup() {
926
+ const injector = core$1.useContext();
927
+ const commander = injector.get(core$1.Commander);
928
+ const selection = injector.get(core$1.Selection);
929
+ core$1.onBreak(ev => {
930
+ const isEmpty = this.state.slot.isEmpty;
931
+ const afterSlot = ev.target.cut(ev.data.index);
932
+ afterSlot.removeAttribute(headingAttr);
933
+ const nextParagraph = new ParagraphComponent(injector, {
934
+ slot: afterSlot
935
+ });
936
+ if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
937
+ this.parentComponent instanceof HighlightBoxComponent)) {
938
+ commander.insertAfter(nextParagraph, this.parentComponent);
939
+ commander.removeComponent(this);
940
+ }
941
+ else {
942
+ commander.insertAfter(nextParagraph, this);
943
+ }
944
+ selection.setPosition(afterSlot, 0);
945
+ ev.preventDefault();
946
+ });
947
+ }
948
+ }
949
+ ParagraphComponent.componentName = 'ParagraphComponent';
950
+ ParagraphComponent.type = core$1.ContentType.BlockComponent;
951
+ function ParagraphView(props) {
952
+ const adapter = core.inject(platformBrowser.DomAdapter);
953
+ const readonly = useReadonly();
954
+ const output = useOutput();
955
+ return () => {
956
+ const slot = props.component.state.slot;
957
+ return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: adapter.slotRender(slot, children => {
958
+ return (core$1.createVNode('div', null, children));
959
+ }, readonly() || output()) }));
960
+ };
961
+ }
962
+ const paragraphComponentLoader = {
963
+ match(element, returnableContentTypes) {
964
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
965
+ },
966
+ read(element, textbus, slotParser) {
967
+ const content = /^P|H[1-6]$/.test(element.tagName) ? element : element.children[0];
968
+ const delta = slotParser(new core$1.Slot([
969
+ core$1.ContentType.Text,
970
+ core$1.ContentType.InlineComponent,
971
+ core$1.ContentType.BlockComponent
972
+ ]), content).toDelta();
973
+ const results = deltaToBlock(delta, textbus);
974
+ if (results.length === 1) {
975
+ return results[0];
976
+ }
977
+ const containerSlot = new core$1.Slot([
978
+ core$1.ContentType.BlockComponent
979
+ ]);
980
+ results.forEach(item => {
981
+ containerSlot.insert(item);
982
+ });
983
+ return containerSlot;
984
+ }
985
+ };
986
+ function deltaToBlock(delta, textbus) {
987
+ const results = [];
988
+ let slot = null;
989
+ for (const item of delta) {
990
+ if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
991
+ if (!slot) {
992
+ slot = new core$1.Slot([
993
+ core$1.ContentType.InlineComponent,
994
+ core$1.ContentType.Text
995
+ ]);
996
+ delta.attributes.forEach((value, key) => {
997
+ slot.setAttribute(key, value);
998
+ });
999
+ results.push(new ParagraphComponent(textbus, {
1000
+ slot
1001
+ }));
1002
+ }
1003
+ slot.insert(item.insert, item.formats);
1004
+ }
1005
+ else {
1006
+ results.push(item.insert);
1007
+ slot = null;
1008
+ }
1009
+ }
1010
+ return results;
1011
+ }
1012
+
1013
+ const languageList = [{
1014
+ label: 'JavaScript',
1015
+ value: 'JavaScript',
1016
+ }, {
1017
+ label: 'HTML',
1018
+ value: 'HTML',
737
1019
  }, {
738
1020
  label: 'CSS',
739
1021
  value: 'CSS',
@@ -758,6 +1040,15 @@ const languageList = [{
758
1040
  }, {
759
1041
  label: 'Go',
760
1042
  value: 'Go'
1043
+ }, {
1044
+ label: 'Kotlin',
1045
+ value: 'kotlin'
1046
+ }, {
1047
+ label: 'Python',
1048
+ value: 'python'
1049
+ }, {
1050
+ label: 'PHP',
1051
+ value: 'php'
761
1052
  }, {
762
1053
  label: 'JSON',
763
1054
  value: 'JSON',
@@ -782,6 +1073,9 @@ const languageList = [{
782
1073
  }, {
783
1074
  label: 'Shell',
784
1075
  value: 'shell',
1076
+ }, {
1077
+ label: 'Katex',
1078
+ value: 'latex',
785
1079
  }, {
786
1080
  label: 'Yaml',
787
1081
  value: 'yaml',
@@ -800,11 +1094,16 @@ const languageList = [{
800
1094
  }, {
801
1095
  label: 'Dart',
802
1096
  value: 'dart',
1097
+ }, {
1098
+ label: 'Rust',
1099
+ value: 'rust',
803
1100
  }, {
804
1101
  label: '',
805
1102
  value: '',
806
1103
  }];
807
1104
  const sourceCodeThemes = [
1105
+ 'xnote-dark',
1106
+ 'xnote-dark-blue',
808
1107
  'github',
809
1108
  'atom-one-dark',
810
1109
  'foundation',
@@ -823,42 +1122,27 @@ function createCodeSlot() {
823
1122
  class SourceCodeComponent extends core$1.Component {
824
1123
  constructor() {
825
1124
  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
- }
1125
+ this.focus = new core$1.BehaviorSubject(false);
1126
+ this.cancelEmphasize = () => {
1127
+ const selection = this.textbus.get(core$1.Selection);
1128
+ const slots = this.state.slots;
1129
+ const { startSlot, endSlot } = selection;
1130
+ let startIndex = slots.findIndex(i => i.slot === startSlot);
1131
+ const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
1132
+ for (; startIndex < endIndex; startIndex++) {
1133
+ slots[startIndex].emphasize = false;
845
1134
  }
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
- }
1135
+ };
1136
+ this.emphasize = () => {
1137
+ const selection = this.textbus.get(core$1.Selection);
1138
+ const slots = this.state.slots;
1139
+ const { startSlot, endSlot } = selection;
1140
+ let startIndex = slots.findIndex(i => i.slot === startSlot);
1141
+ const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
1142
+ for (; startIndex < endIndex; startIndex++) {
1143
+ slots[startIndex].emphasize = true;
860
1144
  }
861
- });
1145
+ };
862
1146
  }
863
1147
  static fromJSON(textbus, json) {
864
1148
  const registry = textbus.get(core$1.Registry);
@@ -880,7 +1164,9 @@ class SourceCodeComponent extends core$1.Component {
880
1164
  const selection = core$1.useContext(core$1.Selection);
881
1165
  core$1.onBreak(ev => {
882
1166
  const slots = this.state.slots;
883
- if (ev.target.isEmpty && ev.target === slots[slots.length - 1].slot) {
1167
+ const parentComponent = selection.commonAncestorComponent;
1168
+ const parentSlot = parentComponent.parent;
1169
+ if (parentSlot && ev.target.isEmpty && ev.target === slots[slots.length - 1].slot) {
884
1170
  const prevSlot = slots[slots.length - 2];
885
1171
  if (prevSlot === null || prevSlot === void 0 ? void 0 : prevSlot.slot.isEmpty) {
886
1172
  const slot = new core$1.Slot([
@@ -890,8 +1176,6 @@ class SourceCodeComponent extends core$1.Component {
890
1176
  const paragraph = new ParagraphComponent(textbus, {
891
1177
  slot
892
1178
  });
893
- const parentComponent = selection.commonAncestorComponent;
894
- const parentSlot = parentComponent.parent;
895
1179
  const index = parentSlot.indexOf(parentComponent);
896
1180
  parentSlot.retain(index + 1);
897
1181
  slots.pop();
@@ -996,7 +1280,7 @@ class SourceCodeComponent extends core$1.Component {
996
1280
  },
997
1281
  action() {
998
1282
  if (selection.isCollapsed) {
999
- commander.insert(' ');
1283
+ commander.insert(' ');
1000
1284
  return;
1001
1285
  }
1002
1286
  const blocks = selection.getBlocks();
@@ -1029,68 +1313,66 @@ class SourceCodeComponent extends core$1.Component {
1029
1313
  }
1030
1314
  });
1031
1315
  }
1316
+ removeSlot(slot) {
1317
+ const slots = this.state.slots;
1318
+ const index = slots.findIndex(i => i.slot === slot);
1319
+ if (index > -1) {
1320
+ slots.splice(index, 1);
1321
+ return true;
1322
+ }
1323
+ return false;
1324
+ }
1032
1325
  }
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) {
1326
+ SourceCodeComponent.type = core$1.ContentType.BlockComponent;
1327
+ SourceCodeComponent.componentName = 'SourceCodeComponent';
1328
+ SourceCodeComponent.zenCoding = {
1329
+ key: ['Enter', ' '],
1330
+ match(c, textbus) {
1331
+ const selection = textbus.get(core$1.Selection);
1332
+ if (selection.commonAncestorComponent instanceof ParagraphComponent) {
1052
1333
  const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
1053
1334
  const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
1054
1335
  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)) {
1336
+ }
1337
+ return false;
1338
+ },
1339
+ createState(content) {
1340
+ const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
1341
+ for (const item of languageList) {
1342
+ const reg = new RegExp(`^${matchString}$`, 'i');
1343
+ if (reg.test(item.label || item.value)) {
1078
1344
  return {
1079
- lang: 'TypeScript',
1345
+ lang: item.value,
1080
1346
  theme: '',
1081
1347
  lineNumber: true,
1082
1348
  slots: [createCodeSlot()]
1083
1349
  };
1084
1350
  }
1351
+ }
1352
+ if (/^js$/i.test(matchString)) {
1353
+ return {
1354
+ lang: 'JavaScript',
1355
+ theme: '',
1356
+ lineNumber: true,
1357
+ slots: [createCodeSlot()]
1358
+ };
1359
+ }
1360
+ if (/^ts$/i.test(matchString)) {
1085
1361
  return {
1086
- lang: '',
1362
+ lang: 'TypeScript',
1087
1363
  theme: '',
1088
1364
  lineNumber: true,
1089
1365
  slots: [createCodeSlot()]
1090
1366
  };
1091
1367
  }
1368
+ return {
1369
+ lang: '',
1370
+ theme: '',
1371
+ lineNumber: true,
1372
+ slots: [createCodeSlot()]
1373
+ };
1092
1374
  }
1093
- });
1375
+ };
1094
1376
  function SourceCodeView(props) {
1095
1377
  const adapter = core.inject(platformBrowser.DomAdapter);
1096
1378
  const isFocus = core.createSignal(false);
@@ -1119,7 +1401,7 @@ function SourceCodeView(props) {
1119
1401
  }
1120
1402
  const input = core.inject(platformBrowser.Input);
1121
1403
  function updateCaret() {
1122
- input.caret.refresh(false);
1404
+ input.caret.refresh();
1123
1405
  }
1124
1406
  const readonly = useReadonly();
1125
1407
  const output = useOutput();
@@ -1156,33 +1438,11 @@ function SourceCodeView(props) {
1156
1438
  }
1157
1439
  }
1158
1440
  }
1159
- function nodesToVNodes(slot, nodes, index) {
1160
- return nodes.map(i => {
1161
- const location = {
1162
- slot,
1163
- startIndex: index,
1164
- endIndex: index + i.textContent.length
1165
- };
1166
- if (i.nodeType === Node.ELEMENT_NODE) {
1167
- const childNodes = Array.from(i.childNodes);
1168
- const vEle = core$1.createVNode('span', {
1169
- class: i.className
1170
- }, nodesToVNodes(slot, childNodes, index));
1171
- index = location.endIndex;
1172
- vEle.location = Object.assign({}, location);
1173
- return vEle;
1174
- }
1175
- index = location.endIndex;
1176
- const textNode = new core$1.VTextNode(i.textContent);
1177
- textNode.location = location;
1178
- return textNode;
1179
- });
1180
- }
1181
- return (jsxRuntime.jsxs("pre", { ref: props.rootRef, class: {
1441
+ return (jsxRuntime.jsxs("div", { ref: props.rootRef, class: {
1182
1442
  'xnote-source-code': true,
1183
1443
  'xnote-source-code-line-number': state.lineNumber,
1184
1444
  [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 => {
1445
+ }, "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
1446
  return {
1187
1447
  label: jsxRuntime.jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
1188
1448
  value: item.value
@@ -1208,7 +1468,7 @@ function SourceCodeView(props) {
1208
1468
  }
1209
1469
  ], children: [jsxRuntime.jsx("div", { class: "xnote-source-code-line-number-bg", style: {
1210
1470
  width: Math.max(String(slots.length).length, 2.5) + 'em'
1211
- } }), jsxRuntime.jsx("div", { onScroll: updateCaret, class: {
1471
+ } }), jsxRuntime.jsx("pre", { onScroll: updateCaret, class: {
1212
1472
  'xnote-source-code-content': true,
1213
1473
  'xnote-source-code-content-highlight': blockHighlight
1214
1474
  }, style: {
@@ -1232,20 +1492,44 @@ function SourceCodeView(props) {
1232
1492
  return core$1.createVNode('div', {
1233
1493
  class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
1234
1494
  }, [
1235
- core$1.createVNode('div', { class: 'xnote-source-code-line-content' }, children)
1495
+ core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
1236
1496
  ]);
1237
1497
  }, readonly());
1238
1498
  }) }), jsxRuntime.jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
1239
1499
  };
1240
1500
  }
1501
+ function nodesToVNodes(slot, nodes, index) {
1502
+ return nodes.map(i => {
1503
+ const location = {
1504
+ slot,
1505
+ startIndex: index,
1506
+ endIndex: index + i.textContent.length
1507
+ };
1508
+ if (i.nodeType === Node.ELEMENT_NODE) {
1509
+ const childNodes = Array.from(i.childNodes);
1510
+ const vEle = core$1.createVNode('span', {
1511
+ class: i.className
1512
+ }, nodesToVNodes(slot, childNodes, index));
1513
+ index = location.endIndex;
1514
+ vEle.location = Object.assign({}, location);
1515
+ return vEle;
1516
+ }
1517
+ index = location.endIndex;
1518
+ const textNode = new core$1.VTextNode(i.textContent);
1519
+ textNode.location = location;
1520
+ return textNode;
1521
+ });
1522
+ }
1241
1523
  const sourceCodeComponentLoader = {
1242
- match(element) {
1243
- return element.tagName === 'PRE';
1524
+ match(element, returnableContentTypes) {
1525
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
1526
+ ((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
1527
+ element.tagName === 'PRE');
1244
1528
  },
1245
1529
  read(el, textbus) {
1246
- const lines = el.querySelectorAll('.xnote-source-code-line');
1247
1530
  let slots = [];
1248
- if (lines.length) {
1531
+ if (el.tagName === 'DIV') {
1532
+ const lines = el.querySelectorAll('.xnote-source-code-line');
1249
1533
  slots = Array.from(lines).map(i => {
1250
1534
  const code = i.innerText.replace(/[\s\n]+$/, '');
1251
1535
  const item = createCodeSlot();
@@ -1266,9 +1550,10 @@ const sourceCodeComponentLoader = {
1266
1550
  });
1267
1551
  }
1268
1552
  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'),
1553
+ lang: el.dataset.lang || '',
1554
+ theme: el.dataset.theme || '',
1555
+ lineNumber: el.dataset.lineNumber === 'true',
1556
+ autoBreak: el.dataset.autoBreak === 'true',
1272
1557
  slots
1273
1558
  });
1274
1559
  },
@@ -1367,15 +1652,26 @@ function AttrTool(props) {
1367
1652
  textIndent: 0
1368
1653
  });
1369
1654
  function updateCheckStates() {
1370
- var _a, _b;
1371
- (_a = props.queryBefore) === null || _a === void 0 ? void 0 : _a.call(props);
1655
+ if (!props.slot && !selection.isSelected) {
1656
+ return;
1657
+ }
1372
1658
  setCheckStates(draft => {
1373
- const textAlignState = query.queryAttribute(textAlignAttr);
1374
- const textIndentState = query.queryAttribute(textIndentAttr);
1659
+ const range = props.slot ? {
1660
+ startSlot: props.slot,
1661
+ endSlot: props.slot,
1662
+ startOffset: 0,
1663
+ endOffset: props.slot.length
1664
+ } : {
1665
+ startSlot: selection.startSlot,
1666
+ startOffset: selection.startOffset,
1667
+ endSlot: selection.endSlot,
1668
+ endOffset: selection.endOffset
1669
+ };
1670
+ const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
1671
+ const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
1375
1672
  draft.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
1376
1673
  draft.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
1377
1674
  });
1378
- (_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
1379
1675
  }
1380
1676
  updateCheckStates();
1381
1677
  const subscription = refreshService.onRefresh.subscribe(() => {
@@ -1422,165 +1718,81 @@ function AttrTool(props) {
1422
1718
  break;
1423
1719
  }
1424
1720
  }
1425
- return scopedCss.withScopedCSS(exportedId$b, () => {
1721
+ return scopedCss.withScopedCSS(scopedId$c, () => {
1426
1722
  const states = checkStates();
1427
- return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
1723
+ return (jsxRuntime.jsx(Dropdown, { width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
1428
1724
  {
1429
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
1725
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', ctrlKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
1430
1726
  value: 't-l'
1431
1727
  }, {
1432
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
1728
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', ctrlKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
1433
1729
  value: 't-r'
1434
1730
  }, {
1435
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
1731
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', ctrlKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
1436
1732
  value: 't-c'
1437
1733
  }, {
1438
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
1734
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', ctrlKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
1439
1735
  value: 't-j'
1440
1736
  }, {
1441
1737
  label: jsxRuntime.jsx(Divider, {}),
1442
1738
  value: ''
1443
1739
  }, {
1444
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
1740
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab' } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
1445
1741
  value: 'i+'
1446
1742
  }, {
1447
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
1743
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
1448
1744
  value: 'i-'
1449
1745
  }
1450
1746
  ], children: props.children || jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
1451
1747
  });
1452
1748
  }
1453
1749
 
1454
- const headingAttr = new core$1.Attribute('Heading', {
1455
- render(node, formatValue) {
1456
- node.classes.add('xnote-' + formatValue);
1457
- }
1458
- });
1459
- const headingAttrLoader = {
1460
- match(element) {
1461
- return /H[1-6]/.test(element.tagName);
1462
- },
1463
- read(element) {
1464
- return {
1465
- attribute: headingAttr,
1466
- value: element.tagName.toLowerCase()
1467
- };
1468
- }
1469
- };
1470
- function registerHeadingShortcut(textbus) {
1471
- const keyboard = textbus.get(core$1.Keyboard);
1472
- const commander = textbus.get(core$1.Commander);
1473
- const selection = textbus.get(core$1.Selection);
1474
- keyboard.addShortcut({
1475
- keymap: {
1476
- key: '123456'.split(''),
1477
- ctrlKey: true
1478
- },
1479
- action(key) {
1480
- commander.applyAttribute(headingAttr, 'h' + key);
1481
- }
1482
- });
1483
- keyboard.addZenCodingInterceptor({
1484
- match(content) {
1485
- return /^#{1,6}$/.test(content);
1486
- },
1487
- try(key) {
1488
- return key === ' ';
1489
- },
1490
- action(content) {
1491
- const commonAncestorSlot = selection.commonAncestorSlot;
1492
- commonAncestorSlot.cut();
1493
- commander.applyAttribute(headingAttr, 'h' + content.length);
1494
- return true;
1495
- }
1496
- });
1497
- }
1498
-
1499
- function useBlockContent(slot) {
1500
- const textbus = core$1.useContext();
1501
- const selection = textbus.get(core$1.Selection);
1502
- core$1.onBreak(ev => {
1503
- if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
1504
- const p = new ParagraphComponent(textbus);
1505
- ev.target.insert(p);
1506
- selection.setPosition(p.state.slot, 0);
1507
- ev.preventDefault();
1508
- }
1509
- });
1510
- core$1.onContentInsert(ev => {
1511
- if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
1512
- (typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
1513
- const p = new ParagraphComponent(textbus);
1514
- const childSlot = p.state.slot;
1515
- childSlot.insert(ev.data.content);
1516
- ev.target.insert(p);
1517
- selection.setPosition(childSlot, childSlot.index);
1518
- ev.preventDefault();
1519
- }
1520
- });
1521
- }
1522
-
1523
- const defaultRowHeight = 30;
1524
- const defaultColumnWidth = 100;
1525
- class TableComponent extends core$1.Component {
1526
- static fromJSON(textbus, json) {
1527
- const registry = textbus.get(core$1.Registry);
1528
- return new TableComponent(textbus, {
1529
- layoutWidth: json.layoutWidth || [],
1530
- rows: json.rows.map(row => {
1531
- return {
1532
- height: row.height,
1533
- cells: row.cells.map(cell => {
1534
- return {
1535
- colspan: cell.colspan,
1536
- rowspan: cell.rowspan,
1537
- slot: registry.createSlot(cell.slot)
1538
- };
1539
- })
1540
- };
1541
- })
1542
- });
1750
+ const defaultRowHeight = 30;
1751
+ const defaultColumnWidth = 100;
1752
+ class TableComponent extends core$1.Component {
1753
+ static fromJSON(textbus, json) {
1754
+ const registry = textbus.get(core$1.Registry);
1755
+ return new TableComponent(textbus, {
1756
+ layoutWidth: json.layoutWidth || [],
1757
+ rows: json.rows.map(row => {
1758
+ return {
1759
+ height: row.height,
1760
+ cells: row.cells.map(cell => {
1761
+ return {
1762
+ colspan: cell.colspan,
1763
+ rowspan: cell.rowspan,
1764
+ slot: registry.createSlot(cell.slot)
1765
+ };
1766
+ })
1767
+ };
1768
+ })
1769
+ });
1543
1770
  }
1544
1771
  constructor(textbus, state = {
1545
- layoutWidth: Array.from({ length: 3 }).fill(100),
1772
+ layoutWidth: Array.from({ length: 5 }).fill(100),
1546
1773
  rows: Array.from({ length: 3 }).map(() => {
1547
1774
  return {
1548
1775
  height: defaultRowHeight,
1549
- cells: Array.from({ length: 3 }).map(() => {
1776
+ cells: Array.from({ length: 5 }).map(() => {
1777
+ const p = new ParagraphComponent(textbus);
1778
+ const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
1779
+ slot.insert(p);
1550
1780
  return {
1551
1781
  rowspan: 1,
1552
1782
  colspan: 1,
1553
- slot: new core$1.Slot([
1554
- core$1.ContentType.Text,
1555
- core$1.ContentType.InlineComponent,
1556
- core$1.ContentType.BlockComponent
1557
- ])
1783
+ slot
1558
1784
  };
1559
1785
  })
1560
1786
  };
1561
1787
  })
1562
1788
  }) {
1563
1789
  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
- });
1790
+ this.selection = this.textbus.get(core$1.Selection);
1791
+ this.focus = new core$1.Subject();
1792
+ this.tableSelection = core.createSignal(null);
1582
1793
  }
1583
1794
  setup() {
1795
+ const selection = core$1.useContext(core$1.Selection);
1584
1796
  core$1.onFocusIn(() => {
1585
1797
  this.focus.next(true);
1586
1798
  });
@@ -1590,12 +1802,42 @@ class TableComponent extends core$1.Component {
1590
1802
  useBlockContent((slot) => {
1591
1803
  return slot.parent === this;
1592
1804
  });
1593
- core$1.onGetRanges(ev => {
1594
- const selectPosition = this.tableSelection();
1805
+ const sub = selection.onChange.subscribe(() => {
1806
+ if (selection.commonAncestorComponent !== this || selection.isCollapsed) {
1807
+ this.tableSelection.set(null);
1808
+ }
1809
+ });
1810
+ core$1.onDestroy(() => {
1811
+ sub.unsubscribe();
1812
+ });
1813
+ const findPosition = (slot) => {
1814
+ let cell = slot;
1815
+ while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== this) {
1816
+ cell = cell.parentSlot;
1817
+ }
1818
+ if (cell) {
1819
+ const rows = this.state.rows;
1820
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
1821
+ const row = rows[rowIndex].cells;
1822
+ for (let colIndex = 0; colIndex < row.length; colIndex++) {
1823
+ const item = row[colIndex].slot;
1824
+ if (item === cell) {
1825
+ return {
1826
+ rowIndex,
1827
+ colIndex
1828
+ };
1829
+ }
1830
+ }
1831
+ }
1832
+ }
1833
+ return null;
1834
+ };
1835
+ const select = (ev, selectPosition) => {
1836
+ this.tableSelection.set(selectPosition);
1595
1837
  if (selectPosition) {
1596
1838
  const cells = [];
1597
- this.state.rows.slice(selectPosition.startRow, selectPosition.endRow + 1).forEach(row => {
1598
- cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn + 1).map(i => i.slot));
1839
+ this.state.rows.slice(selectPosition.startRow, selectPosition.endRow).forEach(row => {
1840
+ cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn).map(i => i.slot));
1599
1841
  });
1600
1842
  ev.useRanges(cells.map(i => {
1601
1843
  return {
@@ -1606,33 +1848,64 @@ class TableComponent extends core$1.Component {
1606
1848
  }));
1607
1849
  ev.preventDefault();
1608
1850
  }
1609
- });
1610
- }
1611
- afterContentCheck() {
1612
- const selection = this.selection;
1613
- const rows = this.state.rows;
1614
- rows.forEach(row => {
1615
- row.cells.forEach(cell => {
1616
- const slot = cell.slot;
1617
- if (slot.isEmpty) {
1618
- const childSlot = new core$1.Slot([
1619
- core$1.ContentType.Text,
1620
- core$1.ContentType.InlineComponent
1621
- ]);
1622
- const p = new ParagraphComponent(this.textbus, {
1623
- slot: childSlot
1624
- });
1625
- slot.insert(p);
1626
- if (slot === selection.anchorSlot) {
1627
- selection.setAnchor(childSlot, 0);
1628
- }
1629
- if (slot === selection.focusSlot) {
1630
- selection.setFocus(childSlot, 0);
1851
+ };
1852
+ core$1.onGetRanges(ev => {
1853
+ var _a;
1854
+ const startPosition = findPosition(selection.startSlot);
1855
+ const endPosition = findPosition(selection.endSlot);
1856
+ if (startPosition && endPosition) {
1857
+ if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
1858
+ if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
1859
+ select(ev, {
1860
+ startColumn: startPosition.colIndex,
1861
+ startRow: startPosition.rowIndex,
1862
+ endColumn: endPosition.colIndex + 1,
1863
+ endRow: endPosition.rowIndex + 1
1864
+ });
1865
+ return;
1631
1866
  }
1867
+ select(ev, null);
1868
+ return;
1632
1869
  }
1633
- });
1870
+ const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
1871
+ const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
1872
+ select(ev, {
1873
+ startColumn,
1874
+ startRow,
1875
+ endColumn: endColumn + 1,
1876
+ endRow: endRow + 1
1877
+ });
1878
+ }
1879
+ else {
1880
+ select(ev, null);
1881
+ }
1634
1882
  });
1635
1883
  }
1884
+ // afterContentCheck() {
1885
+ // const selection = this.selection
1886
+ // const rows = this.state.rows
1887
+ // rows.forEach(row => {
1888
+ // row.cells.forEach(cell => {
1889
+ // const slot = cell.slot
1890
+ // if (slot.isEmpty) {
1891
+ // const childSlot = new Slot([
1892
+ // ContentType.Text,
1893
+ // ContentType.InlineComponent
1894
+ // ])
1895
+ // const p = new ParagraphComponent(this.textbus, {
1896
+ // slot: childSlot
1897
+ // })
1898
+ // slot.insert(p)
1899
+ // if (slot === selection.anchorSlot) {
1900
+ // selection.setAnchor(childSlot, 0)
1901
+ // }
1902
+ // if (slot === selection.focusSlot) {
1903
+ // selection.setFocus(childSlot, 0)
1904
+ // }
1905
+ // }
1906
+ // })
1907
+ // })
1908
+ // }
1636
1909
  deleteColumn(index) {
1637
1910
  this.state.layoutWidth.splice(index, 1);
1638
1911
  this.state.rows.forEach(row => {
@@ -1649,8 +1922,6 @@ class TableComponent extends core$1.Component {
1649
1922
  this.state.rows.forEach(row => {
1650
1923
  const slot = new core$1.Slot([
1651
1924
  core$1.ContentType.BlockComponent,
1652
- core$1.ContentType.InlineComponent,
1653
- core$1.ContentType.Text
1654
1925
  ]);
1655
1926
  slot.insert(new ParagraphComponent(this.textbus, {
1656
1927
  slot: new core$1.Slot([
@@ -1678,8 +1949,6 @@ class TableComponent extends core$1.Component {
1678
1949
  cells: this.state.layoutWidth.map(() => {
1679
1950
  const slot = new core$1.Slot([
1680
1951
  core$1.ContentType.BlockComponent,
1681
- core$1.ContentType.InlineComponent,
1682
- core$1.ContentType.Text
1683
1952
  ]);
1684
1953
  slot.insert(new ParagraphComponent(this.textbus, {
1685
1954
  slot: new core$1.Slot([
@@ -1703,18 +1972,8 @@ class TableComponent extends core$1.Component {
1703
1972
  });
1704
1973
  }
1705
1974
  }
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
- });
1975
+ TableComponent.componentName = 'TableComponent';
1976
+ TableComponent.type = core$1.ContentType.BlockComponent;
1718
1977
 
1719
1978
  const strikeThroughFormatter = new core$1.Formatter('strike', {
1720
1979
  columned: true,
@@ -1751,7 +2010,7 @@ function registerStrikeThroughShortcut(textbus) {
1751
2010
  }
1752
2011
  const strikeThroughFormatLoader = {
1753
2012
  match(element) {
1754
- return /strike|del|s/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
2013
+ return /^(strike|del|s)$/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
1755
2014
  },
1756
2015
  read() {
1757
2016
  return {
@@ -1775,6 +2034,7 @@ class TodolistComponent extends core$1.Component {
1775
2034
  const selection = core$1.useContext(core$1.Selection);
1776
2035
  core$1.onBreak(ev => {
1777
2036
  const slot = ev.target.cut(ev.data.index);
2037
+ slot.removeAttribute(headingAttr);
1778
2038
  if (ev.target.isEmpty && slot.isEmpty) {
1779
2039
  const beforeIndex = this.parent.indexOf(this);
1780
2040
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
@@ -1819,37 +2079,34 @@ class TodolistComponent extends core$1.Component {
1819
2079
  });
1820
2080
  }
1821
2081
  }
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
- };
2082
+ TodolistComponent.type = core$1.ContentType.BlockComponent;
2083
+ TodolistComponent.componentName = 'TodoListComponent';
2084
+ TodolistComponent.zenCoding = {
2085
+ match(content, textbus) {
2086
+ const selection = textbus.get(core$1.Selection);
2087
+ if (selection.commonAncestorComponent instanceof ParagraphComponent) {
2088
+ return /^\[(x|\s)?\]$/.test(content);
1850
2089
  }
2090
+ return false;
2091
+ },
2092
+ key: ' ',
2093
+ createState(content, textbus) {
2094
+ const selection = textbus.get(core$1.Selection);
2095
+ const commonAncestorSlot = selection.commonAncestorSlot;
2096
+ const slot = new core$1.Slot([
2097
+ core$1.ContentType.InlineComponent,
2098
+ core$1.ContentType.Text
2099
+ ]);
2100
+ if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
2101
+ slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
2102
+ }
2103
+ const isChecked = content.charAt(1) === 'x';
2104
+ return {
2105
+ checked: isChecked,
2106
+ slot
2107
+ };
1851
2108
  }
1852
- });
2109
+ };
1853
2110
  function TodolistView(props) {
1854
2111
  const adapter = core.inject(platformBrowser.DomAdapter);
1855
2112
  const component = props.component;
@@ -1884,7 +2141,7 @@ function TodolistView(props) {
1884
2141
  return core$1.createVNode('div', {
1885
2142
  class: 'xnote-todolist-content'
1886
2143
  }, children);
1887
- }, readonly())] }));
2144
+ }, readonly() || output())] }));
1888
2145
  };
1889
2146
  }
1890
2147
  const todolistComponentLoader = {
@@ -1903,90 +2160,40 @@ const todolistComponentLoader = {
1903
2160
  }
1904
2161
  };
1905
2162
 
1906
- class BlockquoteComponent extends core$1.Component {
1907
- static fromJSON(textbus, json) {
1908
- const slot = textbus.get(core$1.Registry).createSlot(json.slot);
1909
- return new BlockquoteComponent(textbus, {
1910
- slot
1911
- });
1912
- }
1913
- constructor(textbus, state = {
1914
- slot: new core$1.Slot([
1915
- core$1.ContentType.Text,
1916
- core$1.ContentType.InlineComponent,
1917
- core$1.ContentType.BlockComponent
1918
- ])
1919
- }) {
1920
- super(textbus, state);
1921
- }
1922
- setup() {
1923
- useBlockContent(this.state.slot);
1924
- }
2163
+ function toList(textbus, type) {
2164
+ const commander = textbus.get(core$1.Commander);
2165
+ commander.transform({
2166
+ targetType: ListComponent.type,
2167
+ slotFactory() {
2168
+ return new core$1.Slot([
2169
+ core$1.ContentType.InlineComponent,
2170
+ core$1.ContentType.Text
2171
+ ]);
2172
+ },
2173
+ stateFactory(slots) {
2174
+ return slots.map((slot, index) => {
2175
+ return new ListComponent(textbus, {
2176
+ type,
2177
+ reorder: index === 0,
2178
+ slot
2179
+ });
2180
+ });
2181
+ }
2182
+ });
1925
2183
  }
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
- };
2184
+ function registerListShortcut(textbus) {
2185
+ const keyboard = textbus.get(core$1.Keyboard);
2186
+ keyboard.addShortcut({
2187
+ keymap: {
2188
+ key: ['o', 'u'],
2189
+ ctrlKey: true,
2190
+ shiftKey: true
2191
+ },
2192
+ action(key) {
2193
+ toList(textbus, key === 'o' ? 'OrderedList' : 'UnorderedList');
1953
2194
  }
1954
- }
1955
- });
1956
- function BlockquoteView(props) {
1957
- const adapter = core.inject(platformBrowser.DomAdapter);
1958
- const readonly = useReadonly();
1959
- return () => {
1960
- const slot = props.component.state.slot;
1961
- return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
1962
- return core$1.createVNode('div', null, children);
1963
- }, readonly()) }));
1964
- };
2195
+ });
1965
2196
  }
1966
- const blockquoteComponentLoader = {
1967
- match(element) {
1968
- return element.tagName === 'BLOCKQUOTE';
1969
- },
1970
- read(element, textbus, slotParser) {
1971
- const delta = slotParser(new core$1.Slot([
1972
- core$1.ContentType.Text,
1973
- core$1.ContentType.BlockComponent,
1974
- core$1.ContentType.InlineComponent
1975
- ]), element).toDelta();
1976
- const slot = new core$1.Slot([
1977
- core$1.ContentType.BlockComponent,
1978
- core$1.ContentType.InlineComponent,
1979
- core$1.ContentType.Text
1980
- ]);
1981
- deltaToBlock(delta, textbus).forEach(i => {
1982
- slot.insert(i);
1983
- });
1984
- return new BlockquoteComponent(textbus, {
1985
- slot
1986
- });
1987
- },
1988
- };
1989
-
1990
2197
  class ListComponent extends core$1.Component {
1991
2198
  static fromJSON(textbus, json) {
1992
2199
  return new ListComponent(textbus, {
@@ -2008,8 +2215,7 @@ class ListComponent extends core$1.Component {
2008
2215
  const afterContent = parentSlot.sliceContent(index + 1);
2009
2216
  for (const item of afterContent) {
2010
2217
  if (item instanceof ListComponent &&
2011
- item.state.type === 'OrderedList' &&
2012
- item.state.slot.getAttribute(textIndentAttr) === this.state.slot.getAttribute(textIndentAttr)) {
2218
+ item.state.type === 'OrderedList') {
2013
2219
  if (item.state.reorder) {
2014
2220
  break;
2015
2221
  }
@@ -2022,6 +2228,7 @@ class ListComponent extends core$1.Component {
2022
2228
  });
2023
2229
  core$1.onBreak(ev => {
2024
2230
  const slot = ev.target.cut(ev.data.index);
2231
+ slot.removeAttribute(headingAttr);
2025
2232
  if (ev.target.isEmpty && slot.isEmpty) {
2026
2233
  const beforeIndex = this.parent.indexOf(this);
2027
2234
  const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
@@ -2067,39 +2274,55 @@ class ListComponent extends core$1.Component {
2067
2274
  selection.setPosition(slot, 0);
2068
2275
  }
2069
2276
  });
2277
+ core$1.useDynamicShortcut({
2278
+ keymap: {
2279
+ key: 'Tab'
2280
+ },
2281
+ action: () => {
2282
+ Promise.resolve().then(() => updateAfterList(this));
2283
+ return false;
2284
+ }
2285
+ });
2286
+ core$1.useDynamicShortcut({
2287
+ keymap: {
2288
+ key: 'Tab',
2289
+ shiftKey: true
2290
+ },
2291
+ action: () => {
2292
+ Promise.resolve().then(() => updateAfterList(this));
2293
+ return false;
2294
+ }
2295
+ });
2070
2296
  }
2071
2297
  }
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
- };
2298
+ ListComponent.componentName = 'ListComponent';
2299
+ ListComponent.type = core$1.ContentType.BlockComponent;
2300
+ ListComponent.zenCoding = {
2301
+ key: ' ',
2302
+ match(content, textbus) {
2303
+ const selection = textbus.get(core$1.Selection);
2304
+ if (selection.commonAncestorComponent instanceof ParagraphComponent) {
2305
+ return /^([1-9]\.|[+*-])$/.test(content);
2306
+ }
2307
+ return false;
2308
+ },
2309
+ createState(content, textbus) {
2310
+ const selection = textbus.get(core$1.Selection);
2311
+ const commonAncestorSlot = selection.commonAncestorSlot;
2312
+ const slot = new core$1.Slot([
2313
+ core$1.ContentType.InlineComponent,
2314
+ core$1.ContentType.Text
2315
+ ]);
2316
+ if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
2317
+ slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
2100
2318
  }
2319
+ return {
2320
+ type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
2321
+ reorder: true,
2322
+ slot
2323
+ };
2101
2324
  }
2102
- });
2325
+ };
2103
2326
  const step = 26;
2104
2327
  const chars = Array.from({ length: step }).map((_, index) => String.fromCharCode(96 + index + 1));
2105
2328
  function numberToLetter(num) {
@@ -2145,7 +2368,8 @@ function ListComponentView(props) {
2145
2368
  return () => {
2146
2369
  const ListType = component.state.type === 'UnorderedList' ? 'ul' : 'ol';
2147
2370
  const ulIcons = ['•', '◦', '▪'];
2148
- let icon = '';
2371
+ let icon;
2372
+ let listStep = 0;
2149
2373
  const indent = component.state.slot.getAttribute(textIndentAttr) || 0;
2150
2374
  if (ListType === 'ul') {
2151
2375
  icon = ulIcons[indent % 3];
@@ -2153,7 +2377,6 @@ function ListComponentView(props) {
2153
2377
  else {
2154
2378
  const parentSlot = component.parent;
2155
2379
  const index = parentSlot.indexOf(component);
2156
- let listStep = 0;
2157
2380
  if (!component.state.reorder) {
2158
2381
  const beforeContent = parentSlot.sliceContent(0, index);
2159
2382
  while (beforeContent.length) {
@@ -2184,24 +2407,24 @@ function ListComponentView(props) {
2184
2407
  icon = numberToLetter(listStep) + '.';
2185
2408
  }
2186
2409
  }
2187
- return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, class: "xnote-list", style: {
2410
+ return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, "data-reorder": (listStep === 0) + '', class: "xnote-list", style: {
2188
2411
  marginLeft: indent * 24 + 'px'
2189
2412
  }, children: jsxRuntime.jsxs("li", { style: {
2190
2413
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
2191
2414
  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() ?
2415
+ }, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
2193
2416
  jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
2194
2417
  :
2195
2418
  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 => {
2196
2419
  return core$1.createVNode('div', {
2197
2420
  class: 'xnote-list-content'
2198
2421
  }, children);
2199
- }, readonly())] }) }));
2422
+ }, readonly() || output())] }) }));
2200
2423
  };
2201
2424
  }
2202
2425
  const listComponentLoader = {
2203
- match(element) {
2204
- return element.tagName === 'UL' || element.tagName === 'OL';
2426
+ match(element, returnableContentTypes) {
2427
+ return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.tagName === 'UL' || element.tagName === 'OL');
2205
2428
  },
2206
2429
  read(element, textbus, slotParser) {
2207
2430
  const type = element.tagName === 'OL' ? 'OrderedList' : 'UnorderedList';
@@ -2212,7 +2435,7 @@ const listComponentLoader = {
2212
2435
  ]), element.querySelector('.xnote-list-content') || document.createElement('div'));
2213
2436
  return new ListComponent(textbus, {
2214
2437
  slot,
2215
- reorder: true,
2438
+ reorder: element.dataset.reorder !== 'false',
2216
2439
  type
2217
2440
  });
2218
2441
  }
@@ -2255,140 +2478,58 @@ function useActiveBlock() {
2255
2478
  sourceCode: false,
2256
2479
  highlightBox: false
2257
2480
  });
2258
- function updateCheckStates() {
2481
+ function updateCheckStates(range) {
2259
2482
  setCheckStates(draft => {
2260
- const heading = query.queryAttribute(headingAttr);
2261
- draft.paragraph = query.queryComponent(ParagraphComponent).state === core$1.QueryStateType.Enabled;
2483
+ const heading = query.queryAttributeByRange(headingAttr, range);
2484
+ draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
2262
2485
  draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
2263
2486
  if (heading.state === core$1.QueryStateType.Enabled) {
2264
2487
  draft[heading.value] = true;
2265
2488
  draft.paragraph = false;
2266
2489
  }
2267
- const queryList = query.queryComponent(ListComponent);
2490
+ const queryList = query.queryComponentByRange(ListComponent, range);
2268
2491
  draft.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
2269
2492
  draft.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
2270
- draft.table = query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled;
2271
- draft.todolist = query.queryComponent(TodolistComponent).state === core$1.QueryStateType.Enabled;
2272
- draft.blockquote = query.queryComponent(BlockquoteComponent).state === core$1.QueryStateType.Enabled;
2273
- draft.sourceCode = query.queryComponent(SourceCodeComponent).state === core$1.QueryStateType.Enabled;
2493
+ draft.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
2494
+ draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
2495
+ draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
2496
+ draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
2274
2497
  });
2275
2498
  }
2276
- updateCheckStates();
2277
2499
  const subscription = refreshService.onRefresh.subscribe(() => {
2278
- updateCheckStates();
2500
+ if (!selection.isSelected) {
2501
+ return;
2502
+ }
2503
+ updateCheckStates({
2504
+ startOffset: selection.startOffset,
2505
+ startSlot: selection.startSlot,
2506
+ endSlot: selection.endSlot,
2507
+ endOffset: selection.endOffset
2508
+ });
2279
2509
  });
2280
2510
  core.onUnmounted(() => {
2281
2511
  subscription.unsubscribe();
2282
2512
  });
2283
2513
  return function (slot = null) {
2284
2514
  if (slot) {
2285
- const snapshot = selection.createSnapshot();
2286
- selection.setBaseAndExtent(slot, 0, slot, slot.length);
2287
- updateCheckStates();
2288
- snapshot.restore();
2515
+ updateCheckStates({
2516
+ startOffset: 0,
2517
+ endOffset: slot.length,
2518
+ startSlot: slot,
2519
+ endSlot: slot
2520
+ });
2289
2521
  }
2290
- return checkStates();
2291
- };
2292
- }
2293
-
2294
- class HighlightBoxComponent extends core$1.Component {
2295
- static fromJSON(textbus, json) {
2296
- return new HighlightBoxComponent(textbus, {
2297
- type: json.type,
2298
- slot: textbus.get(core$1.Registry).createSlot(json.slot)
2299
- });
2300
- }
2301
- constructor(textbus, state = {
2302
- type: '',
2303
- slot: new core$1.Slot([
2304
- core$1.ContentType.BlockComponent,
2305
- core$1.ContentType.InlineComponent,
2306
- core$1.ContentType.Text
2307
- ])
2308
- }) {
2309
- super(textbus, state);
2310
- }
2311
- setup() {
2312
- useBlockContent(this.state.slot);
2313
- }
2314
- }
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
- });
2333
- function HighlightBoxView(props) {
2334
- const adapter = core.inject(platformBrowser.DomAdapter);
2335
- const readonly = useReadonly();
2336
- const output = useOutput();
2337
- const emoji = [];
2338
- for (let i = 0x1F600; i <= 0x1F64F; i++) {
2339
- emoji.push(i);
2340
- }
2341
- const dropdownRef = core.createRef();
2342
- function setType(type) {
2343
- var _a;
2344
- (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
2345
- props.component.state.type = type;
2346
- }
2347
- return () => {
2348
- const { state, name } = props.component;
2349
- if (readonly() || output()) {
2350
- return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
2351
- return core$1.createVNode('div', {
2352
- class: 'xnote-highlight-box-content'
2353
- }, children);
2354
- }, readonly())] }));
2522
+ else if (selection.isSelected) {
2523
+ updateCheckStates({
2524
+ startOffset: selection.startOffset,
2525
+ startSlot: selection.startSlot,
2526
+ endSlot: selection.endSlot,
2527
+ endOffset: selection.endOffset
2528
+ });
2355
2529
  }
2356
- return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "260px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [HighlightBoxComponent.defaultTypes.map(icon => {
2357
- return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
2358
- }), jsxRuntime.jsx(Divider, {}), emoji.map(i => {
2359
- const icon = String.fromCodePoint(i);
2360
- return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
2361
- })] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
2362
- return core$1.createVNode('div', {
2363
- class: 'xnote-highlight-box-content'
2364
- }, children);
2365
- }, readonly())] }));
2530
+ return checkStates();
2366
2531
  };
2367
2532
  }
2368
- const highlightBoxComponentLoader = {
2369
- match(element) {
2370
- return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
2371
- },
2372
- read(element, textbus, slotParser) {
2373
- const delta = slotParser(new core$1.Slot([
2374
- core$1.ContentType.BlockComponent,
2375
- core$1.ContentType.InlineComponent,
2376
- core$1.ContentType.Text
2377
- ]), element.querySelector('.xnote-highlight-box-content')).toDelta();
2378
- const slot = new core$1.Slot([
2379
- core$1.ContentType.BlockComponent,
2380
- core$1.ContentType.InlineComponent,
2381
- core$1.ContentType.Text
2382
- ]);
2383
- deltaToBlock(delta, textbus).forEach(i => {
2384
- slot.insert(i);
2385
- });
2386
- return new HighlightBoxComponent(textbus, {
2387
- type: element.dataset.icon || '',
2388
- slot
2389
- });
2390
- }
2391
- };
2392
2533
 
2393
2534
  function useBlockTransform() {
2394
2535
  const commander = core.inject(core$1.Commander);
@@ -2410,17 +2551,16 @@ function useBlockTransform() {
2410
2551
  commander.unApplyAttribute(headingAttr);
2411
2552
  commander.transform({
2412
2553
  targetType: ParagraphComponent.type,
2413
- multipleSlot: false,
2414
2554
  slotFactory() {
2415
2555
  return new core$1.Slot([
2416
2556
  core$1.ContentType.InlineComponent,
2417
2557
  core$1.ContentType.Text
2418
2558
  ]);
2419
2559
  },
2420
- stateFactory(slot) {
2421
- return new ParagraphComponent(textbus, {
2560
+ stateFactory(slots) {
2561
+ return slots.map(slot => new ParagraphComponent(textbus, {
2422
2562
  slot
2423
- });
2563
+ }));
2424
2564
  }
2425
2565
  });
2426
2566
  break;
@@ -2439,78 +2579,28 @@ function useBlockTransform() {
2439
2579
  commander.unApplyAttribute(headingAttr);
2440
2580
  commander.transform({
2441
2581
  targetType: TodolistComponent.type,
2442
- multipleSlot: false,
2443
2582
  slotFactory() {
2444
2583
  return new core$1.Slot([
2445
2584
  core$1.ContentType.InlineComponent,
2446
2585
  core$1.ContentType.Text
2447
2586
  ]);
2448
2587
  },
2449
- stateFactory(slot) {
2450
- return new TodolistComponent(textbus, {
2451
- checked: false,
2452
- slot
2453
- });
2454
- }
2455
- });
2456
- break;
2457
- case 'ol':
2458
- case 'ul':
2459
- {
2460
- commander.transform({
2461
- targetType: ListComponent.type,
2462
- multipleSlot: false,
2463
- slotFactory() {
2464
- return new core$1.Slot([
2465
- core$1.ContentType.InlineComponent,
2466
- core$1.ContentType.Text
2467
- ]);
2468
- },
2469
- stateFactory(slot) {
2470
- return new ListComponent(textbus, {
2471
- type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
2472
- reorder: true,
2588
+ stateFactory(slots) {
2589
+ return slots.map(slot => {
2590
+ return new TodolistComponent(textbus, {
2591
+ checked: false,
2473
2592
  slot
2474
- });
2475
- }
2476
- });
2477
- }
2478
- break;
2479
- case 'blockquote':
2480
- {
2481
- const state = query.queryComponent(BlockquoteComponent);
2482
- if (state.state === core$1.QueryStateType.Enabled) {
2483
- const current = state.value;
2484
- const parent = current.parent;
2485
- const index = parent.indexOf(current);
2486
- parent.retain(index);
2487
- commander.removeComponent(current);
2488
- current.__slots__.get(0).sliceContent().forEach(i => {
2489
- parent.insert(i);
2490
- });
2491
- }
2492
- else {
2493
- const block = new BlockquoteComponent(textbus);
2494
- const slot = block.state.slot;
2495
- if (selection.startSlot === selection.endSlot) {
2496
- const parentComponent = selection.startSlot.parent;
2497
- const parentSlot = parentComponent.parent;
2498
- const position = parentSlot.indexOf(parentComponent);
2499
- slot.insert(parentComponent);
2500
- parentSlot.retain(position);
2501
- parentSlot.insert(block);
2502
- }
2503
- else {
2504
- const commonAncestorSlot = selection.commonAncestorSlot;
2505
- const scope = selection.getCommonAncestorSlotScope();
2506
- commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
2507
- slot.insert(i);
2508
- });
2509
- commonAncestorSlot.retain(scope.startOffset);
2510
- commonAncestorSlot.insert(block);
2511
- }
2593
+ });
2594
+ });
2512
2595
  }
2513
- }
2596
+ });
2597
+ break;
2598
+ case 'ol':
2599
+ case 'ul':
2600
+ toList(textbus, value === 'ol' ? 'OrderedList' : 'UnorderedList');
2601
+ break;
2602
+ case 'blockquote':
2603
+ toBlockquote(textbus);
2514
2604
  break;
2515
2605
  case 'sourceCode':
2516
2606
  {
@@ -2518,16 +2608,17 @@ function useBlockTransform() {
2518
2608
  if (state.state === core$1.QueryStateType.Enabled) {
2519
2609
  commander.transform({
2520
2610
  targetType: ParagraphComponent.type,
2521
- multipleSlot: false,
2522
2611
  slotFactory() {
2523
2612
  return new core$1.Slot([
2524
2613
  core$1.ContentType.InlineComponent,
2525
2614
  core$1.ContentType.Text
2526
2615
  ]);
2527
2616
  },
2528
- stateFactory(slot) {
2529
- return new ParagraphComponent(textbus, {
2530
- slot
2617
+ stateFactory(slots) {
2618
+ return slots.map(slot => {
2619
+ return new ParagraphComponent(textbus, {
2620
+ slot
2621
+ });
2531
2622
  });
2532
2623
  }
2533
2624
  });
@@ -2535,24 +2626,23 @@ function useBlockTransform() {
2535
2626
  else {
2536
2627
  commander.transform({
2537
2628
  targetType: SourceCodeComponent.type,
2538
- multipleSlot: true,
2539
2629
  slotFactory() {
2540
2630
  return new core$1.Slot([
2541
2631
  core$1.ContentType.Text
2542
2632
  ]);
2543
2633
  },
2544
2634
  stateFactory(slots) {
2545
- return new SourceCodeComponent(textbus, {
2546
- lang: '',
2547
- lineNumber: true,
2548
- autoBreak: true,
2549
- slots: slots.map(slot => {
2550
- return {
2551
- slot,
2552
- emphasize: false
2553
- };
2554
- })
2555
- });
2635
+ return [new SourceCodeComponent(textbus, {
2636
+ lang: '',
2637
+ lineNumber: true,
2638
+ autoBreak: true,
2639
+ slots: slots.map(slot => {
2640
+ return {
2641
+ slot,
2642
+ emphasize: false
2643
+ };
2644
+ })
2645
+ })];
2556
2646
  }
2557
2647
  });
2558
2648
  }
@@ -2601,7 +2691,7 @@ function useBlockTransform() {
2601
2691
  function BlockTool() {
2602
2692
  const checkStates = useActiveBlock();
2603
2693
  const transform = useBlockTransform();
2604
- return scopedCss.withScopedCSS(exportedId$b, () => {
2694
+ return scopedCss.withScopedCSS(scopedId$c, () => {
2605
2695
  const states = checkStates();
2606
2696
  const types = [
2607
2697
  [states.paragraph, 'xnote-icon-pilcrow'],
@@ -2616,7 +2706,7 @@ function BlockTool() {
2616
2706
  [states.todolist, 'xnote-icon-checkbox-checked'],
2617
2707
  [states.blockquote, 'xnote-icon-quotes-right'],
2618
2708
  [states.sourceCode, 'xnote-icon-source-code'],
2619
- [states.highlightBox, 'xnote-icon-paint-bucket'],
2709
+ [states.highlightBox, 'xnote-icon-highlight-box'],
2620
2710
  ];
2621
2711
  let currentType = 'xnote-icon-pilcrow';
2622
2712
  for (const t of types) {
@@ -2625,27 +2715,48 @@ function BlockTool() {
2625
2715
  break;
2626
2716
  }
2627
2717
  }
2628
- return (jsxRuntime.jsx(Dropdown, { onCheck: transform, trigger: 'hover', menu: [
2718
+ return (jsxRuntime.jsx(Dropdown, { width: 'auto', onCheck: transform, trigger: 'hover', menu: [
2629
2719
  {
2630
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), checked: states.paragraph, children: "\u6B63\u6587" }),
2720
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2721
+ ctrlKey: true,
2722
+ key: '0'
2723
+ } }), checked: states.paragraph, children: "\u6B63\u6587" }),
2631
2724
  value: 'paragraph'
2632
2725
  }, {
2633
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
2726
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2727
+ ctrlKey: true,
2728
+ key: '1'
2729
+ } }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
2634
2730
  value: 'h1'
2635
2731
  }, {
2636
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
2732
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2733
+ ctrlKey: true,
2734
+ key: '2'
2735
+ } }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
2637
2736
  value: 'h2'
2638
2737
  }, {
2639
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
2738
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2739
+ ctrlKey: true,
2740
+ key: '3'
2741
+ } }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
2640
2742
  value: 'h3'
2641
2743
  }, {
2642
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
2744
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2745
+ ctrlKey: true,
2746
+ key: '4'
2747
+ } }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
2643
2748
  value: 'h4'
2644
2749
  }, {
2645
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
2750
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2751
+ ctrlKey: true,
2752
+ key: '5'
2753
+ } }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
2646
2754
  value: 'h5'
2647
2755
  }, {
2648
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
2756
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
2757
+ ctrlKey: true,
2758
+ key: '6'
2759
+ } }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
2649
2760
  value: 'h6'
2650
2761
  }, {
2651
2762
  label: jsxRuntime.jsx(Divider, {}),
@@ -2654,19 +2765,19 @@ function BlockTool() {
2654
2765
  label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), checked: states.todolist, children: "\u5F85\u529E\u4E8B\u9879" }),
2655
2766
  value: 'todolist'
2656
2767
  }, {
2657
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
2768
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'O', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
2658
2769
  value: 'ol'
2659
2770
  }, {
2660
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
2771
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'U', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
2661
2772
  value: 'ul'
2662
2773
  }, {
2663
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
2774
+ label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '\'', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
2664
2775
  value: 'blockquote'
2665
2776
  }, {
2666
2777
  label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }), checked: states.sourceCode, children: "\u4EE3\u7801\u5757" }),
2667
2778
  value: 'sourceCode'
2668
2779
  }, {
2669
- label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paint-bucket" }), checked: states.highlightBox, children: "\u9AD8\u4EAE\u5757" }),
2780
+ label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), checked: states.highlightBox, children: "\u9AD8\u4EAE\u5757" }),
2670
2781
  value: 'highlightBox'
2671
2782
  }
2672
2783
  ], children: jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: currentType }) }) }));
@@ -3032,12 +3143,13 @@ function CodeTool() {
3032
3143
  };
3033
3144
  }
3034
3145
 
3035
- var exportedId$a = "vf-1fbbdf";
3146
+ var scopedId$b = "vf-accb31";
3036
3147
 
3037
3148
  function ColorTool(props) {
3038
3149
  const query = core.inject(core$1.Query);
3039
3150
  const refreshService = core.inject(exports.RefreshService);
3040
3151
  const commander = core.inject(core$1.Commander);
3152
+ const selection = core.inject(core$1.Selection);
3041
3153
  const textColor = core.createSignal('');
3042
3154
  const backgroundColor = core.createSignal('');
3043
3155
  const [viewModel] = hooks.useProduce({
@@ -3045,13 +3157,24 @@ function ColorTool(props) {
3045
3157
  disabled: false,
3046
3158
  });
3047
3159
  function updateCheckState() {
3048
- var _a, _b;
3049
- (_a = props.queryBefore) === null || _a === void 0 ? void 0 : _a.call(props);
3050
- const textState = query.queryFormat(colorFormatter);
3051
- const backgroundState = query.queryFormat(backgroundColorFormatter);
3160
+ if (!props.slot && !selection.isSelected) {
3161
+ return;
3162
+ }
3163
+ const range = props.slot ? {
3164
+ startSlot: props.slot,
3165
+ endSlot: props.slot,
3166
+ startOffset: 0,
3167
+ endOffset: props.slot.length
3168
+ } : {
3169
+ startSlot: selection.startSlot,
3170
+ startOffset: selection.startOffset,
3171
+ endSlot: selection.endSlot,
3172
+ endOffset: selection.endOffset
3173
+ };
3174
+ const textState = query.queryFormatByRange(colorFormatter, range);
3175
+ const backgroundState = query.queryFormatByRange(backgroundColorFormatter, range);
3052
3176
  textColor.set(textState.state === core$1.QueryStateType.Enabled ? textState.value : '');
3053
3177
  backgroundColor.set(backgroundState.state === core$1.QueryStateType.Enabled ? backgroundState.value : '');
3054
- (_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
3055
3178
  }
3056
3179
  const sub = refreshService.onRefresh.subscribe(() => {
3057
3180
  updateCheckState();
@@ -3061,14 +3184,17 @@ function ColorTool(props) {
3061
3184
  sub.unsubscribe();
3062
3185
  });
3063
3186
  const textColors = [
3187
+ '#000',
3064
3188
  '#aaa',
3065
3189
  '#ff2e2e',
3066
3190
  '#ff8d45',
3067
3191
  '#ffdf14',
3068
3192
  '#5eec75',
3069
3193
  '#5dfaff',
3194
+ '#1296db',
3070
3195
  '#617fff',
3071
3196
  '#c459ff',
3197
+ '#fff',
3072
3198
  ];
3073
3199
  const backgroundColors = [
3074
3200
  '#aaa',
@@ -3080,15 +3206,16 @@ function ColorTool(props) {
3080
3206
  '#90a0e5',
3081
3207
  '#c596e0',
3082
3208
  ];
3083
- return scopedCss.withScopedCSS(exportedId$a, () => {
3209
+ return scopedCss.withScopedCSS(scopedId$b, () => {
3084
3210
  const vm = viewModel();
3085
- 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: {
3211
+ return (jsxRuntime.jsx(Dropdown, { style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
3212
+ 'no-background': true,
3086
3213
  active: textColor() === ''
3087
3214
  }, onClick: () => {
3088
3215
  var _a;
3089
3216
  (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
3090
3217
  commander.unApplyFormat(colorFormatter);
3091
- }, children: "A" }), textColors.map(c => {
3218
+ } }), textColors.map(c => {
3092
3219
  return jsxRuntime.jsx("div", { class: {
3093
3220
  active: textColor() === c
3094
3221
  }, onClick: () => {
@@ -3148,6 +3275,9 @@ const isSupportFont = (function () {
3148
3275
  function FontFamilyTool() {
3149
3276
  const currentFontFamily = core.createSignal('');
3150
3277
  const fontFamilyOptions = [{
3278
+ label: '默认',
3279
+ value: ''
3280
+ }, {
3151
3281
  label: '宋体',
3152
3282
  value: 'SimSun, STSong'
3153
3283
  }, {
@@ -3189,7 +3319,12 @@ function FontFamilyTool() {
3189
3319
  }];
3190
3320
  const commander = core.inject(core$1.Commander);
3191
3321
  function check(v) {
3192
- commander.applyFormat(fontFamilyFormatter, v);
3322
+ if (v) {
3323
+ commander.applyFormat(fontFamilyFormatter, v);
3324
+ }
3325
+ else {
3326
+ commander.unApplyFormat(fontFamilyFormatter);
3327
+ }
3193
3328
  }
3194
3329
  const refreshService = core.inject(exports.RefreshService);
3195
3330
  const query = core.inject(core$1.Query);
@@ -3198,7 +3333,7 @@ function FontFamilyTool() {
3198
3333
  const result = query.queryFormat(fontFamilyFormatter);
3199
3334
  const isHighlight = result.state === core$1.QueryStateType.Enabled;
3200
3335
  highlight.set(isHighlight);
3201
- currentFontFamily.set(isHighlight ? result.value : '默认');
3336
+ currentFontFamily.set(isHighlight ? result.value : '');
3202
3337
  });
3203
3338
  core.onUnmounted(() => {
3204
3339
  subscription.unsubscribe();
@@ -3206,7 +3341,7 @@ function FontFamilyTool() {
3206
3341
  return () => {
3207
3342
  var _a;
3208
3343
  return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: fontFamilyOptions.map(i => {
3209
- const disabled = !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v);
3344
+ const disabled = i.value ? !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v) : false;
3210
3345
  return {
3211
3346
  label: jsxRuntime.jsx(MenuItem, { disabled: disabled, checked: currentFontFamily() === i.value, children: i.label }),
3212
3347
  disabled,
@@ -3238,7 +3373,12 @@ function FontSizeTool() {
3238
3373
  ];
3239
3374
  const commander = core.inject(core$1.Commander);
3240
3375
  function check(v) {
3241
- commander.applyFormat(fontSizeFormatter, v);
3376
+ if (v) {
3377
+ commander.applyFormat(fontSizeFormatter, v);
3378
+ }
3379
+ else {
3380
+ commander.unApplyFormat(fontSizeFormatter);
3381
+ }
3242
3382
  }
3243
3383
  const refreshService = core.inject(exports.RefreshService);
3244
3384
  const query = core.inject(core$1.Query);
@@ -3262,144 +3402,413 @@ function FontSizeTool() {
3262
3402
  };
3263
3403
  }
3264
3404
 
3265
- function ItalicTool() {
3266
- const query = core.inject(core$1.Query);
3267
- const refreshService = core.inject(exports.RefreshService);
3268
- const textbus = core.inject(core$1.Textbus);
3269
- const [viewModel, update] = hooks.useProduce({
3270
- highlight: false,
3271
- disabled: false,
3272
- });
3273
- function toggle() {
3274
- toggleItalic(textbus);
3405
+ function ItalicTool() {
3406
+ const query = core.inject(core$1.Query);
3407
+ const refreshService = core.inject(exports.RefreshService);
3408
+ const textbus = core.inject(core$1.Textbus);
3409
+ const [viewModel, update] = hooks.useProduce({
3410
+ highlight: false,
3411
+ disabled: false,
3412
+ });
3413
+ function toggle() {
3414
+ toggleItalic(textbus);
3415
+ }
3416
+ const sub = refreshService.onRefresh.subscribe(() => {
3417
+ const state = query.queryFormat(italicFormatter);
3418
+ update(draft => {
3419
+ draft.highlight = state.state === core$1.QueryStateType.Enabled;
3420
+ });
3421
+ });
3422
+ core.onUnmounted(() => {
3423
+ sub.unsubscribe();
3424
+ });
3425
+ return () => {
3426
+ const vm = viewModel();
3427
+ return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
3428
+ };
3429
+ }
3430
+
3431
+ var scopedId$a = "vf-e74208";
3432
+
3433
+ exports.EditorService = class EditorService {
3434
+ constructor() {
3435
+ this.hideInlineToolbar = false;
3436
+ this.canShowLeftToolbar = true;
3437
+ this.onLeftToolbarCanVisibleChange = new core$1.Subject();
3438
+ }
3439
+ changeLeftToolbarVisible(b) {
3440
+ this.canShowLeftToolbar = b;
3441
+ this.onLeftToolbarCanVisibleChange.next();
3442
+ }
3443
+ };
3444
+ exports.EditorService = __decorate([
3445
+ core.Injectable({
3446
+ provideIn: 'root'
3447
+ })
3448
+ ], exports.EditorService);
3449
+
3450
+ function LinkTool(props) {
3451
+ const selectionBridge = core.inject(platformBrowser.SelectionBridge);
3452
+ const selection = core.inject(core$1.Selection);
3453
+ const commander = core.inject(core$1.Commander);
3454
+ const editorService = core.inject(exports.EditorService);
3455
+ const container = core.inject(platformBrowser.VIEW_CONTAINER);
3456
+ const isShow = core.createSignal(false);
3457
+ const inputRef = core.createRef();
3458
+ function setLink(ev) {
3459
+ ev.preventDefault();
3460
+ const value = inputRef.current.value;
3461
+ if (value) {
3462
+ commander.applyFormat(linkFormatter, {
3463
+ href: value,
3464
+ target: '_blanK'
3465
+ });
3466
+ }
3467
+ isShow.set(false);
3468
+ editorService.hideInlineToolbar = false;
3469
+ }
3470
+ let isClickFromSelf = false;
3471
+ const sub = core$1.fromEvent(document, 'click').subscribe(() => {
3472
+ if (isClickFromSelf) {
3473
+ isClickFromSelf = false;
3474
+ return;
3475
+ }
3476
+ editorService.hideInlineToolbar = false;
3477
+ isShow.set(false);
3478
+ });
3479
+ core.onUnmounted(() => {
3480
+ sub.unsubscribe();
3481
+ });
3482
+ return scopedCss.withScopedCSS(scopedId$a, () => {
3483
+ const containerRect = container.getBoundingClientRect();
3484
+ const rect = isShow() ? selectionBridge.getRect({
3485
+ slot: selection.focusSlot,
3486
+ offset: selection.focusOffset
3487
+ }) : {};
3488
+ return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
3489
+ var _a;
3490
+ isShow.set(true);
3491
+ isClickFromSelf = true;
3492
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
3493
+ }, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
3494
+ jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
3495
+ isClickFromSelf = true;
3496
+ }, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
3497
+ });
3498
+ }
3499
+
3500
+ function StrikeThroughTool() {
3501
+ const query = core.inject(core$1.Query);
3502
+ const refreshService = core.inject(exports.RefreshService);
3503
+ const textbus = core.inject(core$1.Textbus);
3504
+ const [viewModel, update] = hooks.useProduce({
3505
+ highlight: false,
3506
+ disabled: false,
3507
+ });
3508
+ function toggle() {
3509
+ toggleStrikeThrough(textbus);
3510
+ }
3511
+ const sub = refreshService.onRefresh.subscribe(() => {
3512
+ const state = query.queryFormat(strikeThroughFormatter);
3513
+ update(draft => {
3514
+ draft.highlight = state.state === core$1.QueryStateType.Enabled;
3515
+ });
3516
+ });
3517
+ core.onUnmounted(() => {
3518
+ sub.unsubscribe();
3519
+ });
3520
+ return () => {
3521
+ const vm = viewModel();
3522
+ return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
3523
+ };
3524
+ }
3525
+
3526
+ function UnderlineTool() {
3527
+ const query = core.inject(core$1.Query);
3528
+ const refreshService = core.inject(exports.RefreshService);
3529
+ const textbus = core.inject(core$1.Textbus);
3530
+ const [viewModel, update] = hooks.useProduce({
3531
+ highlight: false,
3532
+ disabled: false,
3533
+ });
3534
+ function toggle() {
3535
+ toggleUnderline(textbus);
3536
+ }
3537
+ const sub = refreshService.onRefresh.subscribe(() => {
3538
+ const state = query.queryFormat(underlineFormatter);
3539
+ update(draft => {
3540
+ draft.highlight = state.state === core$1.QueryStateType.Enabled;
3541
+ });
3542
+ });
3543
+ core.onUnmounted(() => {
3544
+ sub.unsubscribe();
3545
+ });
3546
+ return () => {
3547
+ const vm = viewModel();
3548
+ return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
3549
+ };
3550
+ }
3551
+
3552
+ var scopedId$9 = "vf-cf8e1c";
3553
+
3554
+ class FileUploader {
3555
+ }
3556
+
3557
+ class ImageComponent extends core$1.Component {
3558
+ static fromJSON(textbus, json) {
3559
+ return new ImageComponent(textbus, Object.assign({}, json));
3560
+ }
3561
+ }
3562
+ ImageComponent.type = core$1.ContentType.InlineComponent;
3563
+ ImageComponent.componentName = 'ImageComponent';
3564
+ function ImageView(props) {
3565
+ const { name, state } = props.component;
3566
+ const imageRef = core.createRef();
3567
+ const readonly = useReadonly();
3568
+ const output = useOutput();
3569
+ return () => {
3570
+ if (readonly() || output()) {
3571
+ return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
3572
+ width: state.width,
3573
+ height: state.height
3574
+ } }) }));
3575
+ }
3576
+ return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx(DragResize, { source: imageRef, component: props.component, children: jsxRuntime.jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
3577
+ width: state.width,
3578
+ height: state.height
3579
+ } }) }) }));
3580
+ };
3581
+ }
3582
+ const imageComponentLoader = {
3583
+ match(element) {
3584
+ return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
3585
+ },
3586
+ read(element, textbus) {
3587
+ const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
3588
+ return new ImageComponent(textbus, {
3589
+ src: img.src,
3590
+ width: img.style.width || 'auto',
3591
+ height: img.style.height || 'auto'
3592
+ });
3593
+ }
3594
+ };
3595
+
3596
+ class VideoComponent extends core$1.Component {
3597
+ static fromJSON(textbus, json) {
3598
+ return new VideoComponent(textbus, Object.assign({}, json));
3599
+ }
3600
+ setup() {
3601
+ //
3602
+ }
3603
+ }
3604
+ VideoComponent.type = core$1.ContentType.InlineComponent;
3605
+ VideoComponent.componentName = 'VideoComponent';
3606
+ function VideoView(props) {
3607
+ const { name, state } = props.component;
3608
+ const videoRef = core.createRef();
3609
+ const readonly = useReadonly();
3610
+ const output = useOutput();
3611
+ return () => {
3612
+ if (readonly() || output()) {
3613
+ return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
3614
+ width: state.width,
3615
+ height: state.height
3616
+ } }) }));
3617
+ }
3618
+ return (jsxRuntime.jsx("div", { ref: props.rootRef, class: "xnote-video", "data-component": name, children: jsxRuntime.jsx(DragResize, { source: videoRef, component: props.component, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
3619
+ width: state.width,
3620
+ height: state.height
3621
+ } }) }) }));
3622
+ };
3623
+ }
3624
+ const videoComponentLoader = {
3625
+ match(element) {
3626
+ return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
3627
+ },
3628
+ read(element, textbus) {
3629
+ const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
3630
+ return new VideoComponent(textbus, {
3631
+ src: video.src,
3632
+ width: video.style.width || 'auto',
3633
+ height: video.style.height || 'auto'
3634
+ });
3635
+ }
3636
+ };
3637
+
3638
+ class KatexEditor extends core$1.Textbus {
3639
+ constructor() {
3640
+ const adapter = new adapterViewfly.ViewflyAdapter({
3641
+ [SourceCodeComponent.componentName]: SourceCodeView
3642
+ }, (host, root, injector) => {
3643
+ const appInjector = new core.ReflectiveInjector(injector, [{
3644
+ provide: OutputInjectionToken,
3645
+ useValue: true
3646
+ }]);
3647
+ const app = platformBrowser$1.createApp(root, {
3648
+ context: appInjector
3649
+ }).mount(host);
3650
+ return () => {
3651
+ app.destroy();
3652
+ };
3653
+ });
3654
+ const browserModule = new platformBrowser.BrowserModule({
3655
+ adapter,
3656
+ renderTo: () => {
3657
+ return this.host;
3658
+ }
3659
+ });
3660
+ super({
3661
+ components: [
3662
+ SourceCodeComponent
3663
+ ],
3664
+ imports: [browserModule]
3665
+ });
3666
+ this.onValueChange = new core$1.Subject();
3667
+ }
3668
+ mount(host, code) {
3669
+ this.host = host;
3670
+ const model = new SourceCodeComponent(this, {
3671
+ lineNumber: true,
3672
+ autoBreak: true,
3673
+ lang: 'latex',
3674
+ theme: 'github',
3675
+ slots: code.split('\n').map(i => {
3676
+ const slot = new core$1.Slot([core$1.ContentType.Text]);
3677
+ slot.insert(i);
3678
+ return {
3679
+ slot,
3680
+ emphasize: false
3681
+ };
3682
+ })
3683
+ });
3684
+ this.onChange.subscribe(() => {
3685
+ const str = model.state.slots.map(i => {
3686
+ if (i.slot.isEmpty) {
3687
+ return '';
3688
+ }
3689
+ return i.slot.toString();
3690
+ }).join('\n');
3691
+ this.onValueChange.next(str);
3692
+ });
3693
+ return this.render(model);
3694
+ }
3695
+ }
3696
+
3697
+ class KatexComponent extends core$1.Component {
3698
+ static fromJSON(textbus, state) {
3699
+ return new KatexComponent(textbus, state);
3275
3700
  }
3276
- const sub = refreshService.onRefresh.subscribe(() => {
3277
- const state = query.queryFormat(italicFormatter);
3278
- update(draft => {
3279
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
3280
- });
3701
+ constructor(textbus, state = {
3702
+ text: '% \\f is defined as #1f(#2) using the macro\n' +
3703
+ '\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
3704
+ '\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
3705
+ '\\,d\\xi'
3706
+ }) {
3707
+ super(textbus, state);
3708
+ }
3709
+ }
3710
+ KatexComponent.componentName = 'KatexComponent';
3711
+ KatexComponent.type = core$1.ContentType.InlineComponent;
3712
+ function domToVDom(el) {
3713
+ const attrs = {};
3714
+ el.getAttributeNames().forEach(key => {
3715
+ attrs[key] = el.getAttribute(key);
3281
3716
  });
3282
- core.onUnmounted(() => {
3283
- sub.unsubscribe();
3717
+ attrs.children = Array.from(el.childNodes).map(child => {
3718
+ if (child.nodeType === Node.ELEMENT_NODE) {
3719
+ return domToVDom(child);
3720
+ }
3721
+ return child.textContent || '';
3284
3722
  });
3285
- return () => {
3286
- const vm = viewModel();
3287
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
3288
- };
3723
+ return core.jsx(el.tagName.toLowerCase(), attrs);
3289
3724
  }
3290
-
3291
- var exportedId$9 = "vf-269a0b";
3292
-
3293
- function LinkTool(props) {
3294
- const selectionBridge = core.inject(platformBrowser.SelectionBridge);
3295
- const selection = core.inject(core$1.Selection);
3296
- const commander = core.inject(core$1.Commander);
3297
- const container = core.inject(platformBrowser.VIEW_CONTAINER);
3298
- const isShow = core.createSignal(false);
3299
- const inputRef = core.createRef();
3300
- function setLink(ev) {
3301
- ev.preventDefault();
3302
- const value = inputRef.current.value;
3303
- if (value) {
3304
- commander.applyFormat(linkFormatter, {
3305
- href: value,
3306
- target: '_blanK'
3725
+ function KatexComponentView(props) {
3726
+ function toDOM(value) {
3727
+ let htmlString;
3728
+ try {
3729
+ htmlString = Katex.renderToString(value, {
3730
+ displayMode: true,
3731
+ leqno: false,
3732
+ fleqn: false,
3733
+ throwOnError: true,
3734
+ errorColor: '#cc0000',
3735
+ strict: 'warn',
3736
+ output: 'html',
3737
+ trust: false,
3738
+ macros: { '\\f': '#1f(#2)' }
3307
3739
  });
3308
3740
  }
3309
- isShow.set(false);
3310
- }
3311
- let isClickFromSelf = false;
3312
- const sub = core$1.fromEvent(document, 'click').subscribe(() => {
3313
- if (isClickFromSelf) {
3314
- isClickFromSelf = false;
3315
- return;
3741
+ catch (e) {
3742
+ htmlString = '<span style="color: red">公式错误</span>';
3316
3743
  }
3317
- isShow.set(false);
3318
- });
3319
- core.onUnmounted(() => {
3320
- sub.unsubscribe();
3321
- });
3322
- return scopedCss.withScopedCSS(exportedId$9, () => {
3323
- const containerRect = container.getBoundingClientRect();
3324
- const rect = isShow() ? selectionBridge.getRect({
3325
- slot: selection.focusSlot,
3326
- offset: selection.focusOffset
3327
- }) : {};
3328
- return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
3329
- isShow.set(true);
3330
- isClickFromSelf = true;
3331
- setTimeout(() => { var _a; return (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props); }, 10);
3332
- }, arrow: true, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
3333
- jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
3334
- isClickFromSelf = true;
3335
- }, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
3336
- });
3337
- }
3338
-
3339
- function StrikeThroughTool() {
3340
- const query = core.inject(core$1.Query);
3341
- const refreshService = core.inject(exports.RefreshService);
3342
- const textbus = core.inject(core$1.Textbus);
3343
- const [viewModel, update] = hooks.useProduce({
3344
- highlight: false,
3345
- disabled: false,
3346
- });
3347
- function toggle() {
3348
- toggleStrikeThrough(textbus);
3744
+ return new DOMParser().parseFromString(htmlString, 'text/html').body.children[0];
3349
3745
  }
3350
- const sub = refreshService.onRefresh.subscribe(() => {
3351
- const state = query.queryFormat(strikeThroughFormatter);
3352
- update(draft => {
3353
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
3746
+ const selection = core.inject(core$1.Textbus);
3747
+ const editorRef = core.createDynamicRef(node => {
3748
+ const editor = new KatexEditor();
3749
+ editor.mount(node, props.component.state.text).then(() => {
3750
+ editor.focus();
3354
3751
  });
3752
+ selection.blur();
3753
+ const subscription = editor.onValueChange.subscribe((value) => {
3754
+ props.component.state.text = value;
3755
+ }).add(core$1.fromEvent(node, 'mousedown').subscribe(ev => ev.stopPropagation()), core$1.fromEvent(document, 'mousedown').subscribe(() => {
3756
+ var _a;
3757
+ (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
3758
+ }));
3759
+ return () => {
3760
+ subscription.unsubscribe();
3761
+ editor.destroy();
3762
+ };
3355
3763
  });
3356
- core.onUnmounted(() => {
3357
- sub.unsubscribe();
3358
- });
3764
+ const dropdownRef = core.createRef();
3765
+ const output = useOutput();
3766
+ const readonly = useReadonly();
3359
3767
  return () => {
3360
- const vm = viewModel();
3361
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
3768
+ const text = props.component.state.text;
3769
+ return (jsxRuntime.jsx("span", { onClick: () => {
3770
+ var _a;
3771
+ (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(true);
3772
+ }, ref: props.rootRef, "data-component": KatexComponent.componentName, "data-katex": encodeURIComponent(text), class: "xnote-katex", children: (output() || readonly()) ?
3773
+ domToVDom(toDOM(text))
3774
+ :
3775
+ jsxRuntime.jsx(Dropdown, { padding: '0', ref: dropdownRef, trigger: 'none', width: '600px', menu: jsxRuntime.jsx("div", { class: "xnote-katex-input", ref: editorRef }), children: domToVDom(toDOM(text)) }) }));
3362
3776
  };
3363
3777
  }
3364
-
3365
- function UnderlineTool() {
3366
- const query = core.inject(core$1.Query);
3367
- const refreshService = core.inject(exports.RefreshService);
3368
- const textbus = core.inject(core$1.Textbus);
3369
- const [viewModel, update] = hooks.useProduce({
3370
- highlight: false,
3371
- disabled: false,
3372
- });
3373
- function toggle() {
3374
- toggleUnderline(textbus);
3375
- }
3376
- const sub = refreshService.onRefresh.subscribe(() => {
3377
- const state = query.queryFormat(underlineFormatter);
3378
- update(draft => {
3379
- draft.highlight = state.state === core$1.QueryStateType.Enabled;
3778
+ const katexComponentLoader = {
3779
+ match(element) {
3780
+ return element.dataset.component === KatexComponent.componentName;
3781
+ },
3782
+ read(element, textbus) {
3783
+ const value = element.dataset.katex || '';
3784
+ return new KatexComponent(textbus, {
3785
+ text: decodeURIComponent(value)
3380
3786
  });
3381
- });
3382
- core.onUnmounted(() => {
3383
- sub.unsubscribe();
3384
- });
3385
- return () => {
3386
- const vm = viewModel();
3387
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
3388
- };
3389
- }
3390
-
3391
- var exportedId$8 = "vf-cf8e1c";
3787
+ }
3788
+ };
3392
3789
 
3393
3790
  function InsertTool(props) {
3394
3791
  const commander = core.inject(core$1.Commander);
3395
3792
  const selection = core.inject(core$1.Selection);
3396
3793
  const textbus = core.inject(core$1.Textbus);
3794
+ const fileUploader = core.inject(FileUploader, null);
3795
+ const dropdownContextService = core.inject(exports.DropdownContextService);
3397
3796
  function insert(type) {
3398
3797
  var _a;
3399
3798
  const component = (_a = props.slot) === null || _a === void 0 ? void 0 : _a.parent;
3400
3799
  if (!component) {
3401
3800
  return;
3402
3801
  }
3802
+ function insertComponent(comp) {
3803
+ if (props.replace) {
3804
+ commander.replaceComponent(component, comp);
3805
+ }
3806
+ else {
3807
+ commander.insertAfter(comp, component);
3808
+ }
3809
+ dropdownContextService.canHide = true;
3810
+ dropdownContextService.hide(false);
3811
+ }
3403
3812
  switch (type) {
3404
3813
  case 'h1':
3405
3814
  case 'h2':
@@ -3414,12 +3823,12 @@ function InsertTool(props) {
3414
3823
  core$1.ContentType.Text
3415
3824
  ]);
3416
3825
  if (/h[1-6]/.test(type)) {
3417
- slot.setAttribute(headingAttr, +type.substring(1));
3826
+ slot.setAttribute(headingAttr, type);
3418
3827
  }
3419
3828
  const p = new ParagraphComponent(textbus, {
3420
3829
  slot
3421
3830
  });
3422
- commander.insertAfter(p, component);
3831
+ insertComponent(p);
3423
3832
  selection.setPosition(slot, 0);
3424
3833
  }
3425
3834
  break;
@@ -3435,7 +3844,7 @@ function InsertTool(props) {
3435
3844
  reorder: true,
3436
3845
  type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
3437
3846
  });
3438
- commander.insertAfter(list, component);
3847
+ insertComponent(list);
3439
3848
  selection.setPosition(slot, 0);
3440
3849
  }
3441
3850
  break;
@@ -3452,15 +3861,17 @@ function InsertTool(props) {
3452
3861
  emphasize: false
3453
3862
  }]
3454
3863
  });
3455
- commander.insertAfter(comp, component);
3864
+ insertComponent(comp);
3456
3865
  selection.setPosition(slot, 0);
3457
3866
  }
3458
3867
  break;
3459
3868
  case 'table':
3460
3869
  {
3461
3870
  const table = new TableComponent(textbus);
3462
- commander.insertAfter(table, component);
3463
- selection.setPosition(table.state.rows[0].cells[0].slot, 0);
3871
+ insertComponent(table);
3872
+ textbus.nextTick(() => {
3873
+ selection.selectFirstPosition(table, true, true);
3874
+ });
3464
3875
  }
3465
3876
  break;
3466
3877
  case 'todolist':
@@ -3473,31 +3884,56 @@ function InsertTool(props) {
3473
3884
  slot,
3474
3885
  checked: false
3475
3886
  });
3476
- commander.insertAfter(comp, component);
3887
+ insertComponent(comp);
3477
3888
  selection.setPosition(slot, 0);
3478
3889
  }
3479
3890
  break;
3480
3891
  case 'image':
3892
+ if (fileUploader) {
3893
+ Promise.resolve(fileUploader.uploadFile('image')).then(url => {
3894
+ const img = new ImageComponent(textbus, {
3895
+ src: url
3896
+ });
3897
+ commander.insert(img);
3898
+ });
3899
+ }
3481
3900
  break;
3482
3901
  case 'video':
3902
+ if (fileUploader) {
3903
+ Promise.resolve(fileUploader.uploadFile('video')).then(url => {
3904
+ const img = new VideoComponent(textbus, {
3905
+ src: url
3906
+ });
3907
+ commander.insert(img);
3908
+ });
3909
+ }
3483
3910
  break;
3484
3911
  case 'highlightBox':
3485
3912
  {
3486
3913
  const p = new ParagraphComponent(textbus);
3487
3914
  const comp = new HighlightBoxComponent(textbus);
3488
3915
  comp.state.slot.insert(p);
3489
- commander.insertAfter(comp, component);
3916
+ insertComponent(comp);
3490
3917
  selection.setPosition(p.state.slot, 0);
3491
3918
  }
3492
3919
  break;
3920
+ case 'katex':
3921
+ {
3922
+ const p = new ParagraphComponent(textbus);
3923
+ const comp = new KatexComponent(textbus);
3924
+ p.state.slot.insert(comp);
3925
+ insertComponent(p);
3926
+ selection.selectComponent(comp);
3927
+ }
3928
+ break;
3493
3929
  }
3494
3930
  }
3495
- return scopedCss.withScopedCSS(exportedId$8, () => {
3496
- 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" })] });
3931
+ return scopedCss.withScopedCSS(scopedId$9, () => {
3932
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.hideTitle ? null : jsxRuntime.jsx(MenuHeading, { children: props.replace ? '替换为' : '在下面添加' }), 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-hightlight-box" }), children: "\u9AD8\u4EAE\u5757" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('katex'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-function" }), children: "\u6570\u5B66\u516C\u5F0F" })] });
3497
3933
  });
3498
3934
  }
3499
3935
 
3500
- var exportedId$7 = "vf-b05292";
3936
+ var scopedId$8 = "vf-b05292";
3501
3937
 
3502
3938
  const LeftToolbar = core.withAnnotation({
3503
3939
  providers: [exports.RefreshService]
@@ -3507,6 +3943,7 @@ const LeftToolbar = core.withAnnotation({
3507
3943
  const selection = core.inject(core$1.Selection);
3508
3944
  const rootComponentRef = core.inject(core$1.RootComponentRef);
3509
3945
  const refreshService = core.inject(exports.RefreshService);
3946
+ const editorService = core.inject(exports.EditorService);
3510
3947
  const checkStates = useActiveBlock();
3511
3948
  const toBlock = useBlockTransform();
3512
3949
  const activeSlot = core.createSignal(null);
@@ -3525,18 +3962,29 @@ const LeftToolbar = core.withAnnotation({
3525
3962
  top: 0,
3526
3963
  display: false
3527
3964
  });
3965
+ const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
3966
+ updatePosition(d => {
3967
+ d.display = editorService.canShowLeftToolbar;
3968
+ });
3969
+ });
3970
+ core.onUnmounted(() => {
3971
+ sub.unsubscribe();
3972
+ });
3973
+ let isIgnoreMove = false;
3528
3974
  core.onMounted(() => {
3529
3975
  const rootComponent = rootComponentRef.component;
3530
3976
  const docContentContainer = adapter.getNativeNodeBySlot(rootComponent.state.content);
3531
3977
  const sub = core$1.fromEvent(docContentContainer, 'mousemove').pipe(core$1.filter(() => {
3532
- return selection.isCollapsed;
3978
+ return !isIgnoreMove;
3533
3979
  }), core$1.map(ev => {
3980
+ var _a;
3534
3981
  let currentNode = ev.target;
3535
3982
  while (currentNode) {
3536
3983
  const slot = adapter.getSlotByNativeNode(currentNode);
3537
3984
  if (slot) {
3538
- if ((slot === null || slot === void 0 ? void 0 : slot.parent) instanceof SourceCodeComponent || (slot === null || slot === void 0 ? void 0 : slot.parent) instanceof TableComponent) {
3539
- return null;
3985
+ if (((_a = slot === null || slot === void 0 ? void 0 : slot.parent) === null || _a === void 0 ? void 0 : _a.type) === core$1.ContentType.InlineComponent) {
3986
+ currentNode = currentNode.parentNode;
3987
+ continue;
3540
3988
  }
3541
3989
  return slot;
3542
3990
  }
@@ -3551,7 +3999,9 @@ const LeftToolbar = core.withAnnotation({
3551
3999
  activeSlot.set(slot);
3552
4000
  if (slot) {
3553
4001
  checkStates(slot);
3554
- isEmptyBlock.set(slot.parent instanceof ParagraphComponent && slot.isEmpty);
4002
+ isEmptyBlock.set((slot.parent instanceof ParagraphComponent && slot.isEmpty) ||
4003
+ slot.parent instanceof SourceCodeComponent ||
4004
+ slot.parent instanceof TableComponent);
3555
4005
  const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
3556
4006
  updatePosition(draft => {
3557
4007
  const containerRect = docContentContainer.getBoundingClientRect();
@@ -3604,18 +4054,6 @@ const LeftToolbar = core.withAnnotation({
3604
4054
  isShow.set(true);
3605
4055
  }));
3606
4056
  });
3607
- let snapshot = null;
3608
- function queryBefore() {
3609
- const slot = activeSlot();
3610
- if (slot) {
3611
- snapshot = selection.createSnapshot();
3612
- selection.selectSlot(slot);
3613
- }
3614
- }
3615
- function queryAfter() {
3616
- snapshot === null || snapshot === void 0 ? void 0 : snapshot.restore();
3617
- snapshot = null;
3618
- }
3619
4057
  function applyBefore() {
3620
4058
  const slot = activeSlot();
3621
4059
  if (slot) {
@@ -3656,11 +4094,15 @@ const LeftToolbar = core.withAnnotation({
3656
4094
  }
3657
4095
  }
3658
4096
  const isEmptyBlock = core.createSignal(true);
3659
- return scopedCss.withScopedCSS(exportedId$7, () => {
4097
+ function changeIgnoreMove(b) {
4098
+ isIgnoreMove = b;
4099
+ }
4100
+ return scopedCss.withScopedCSS(scopedId$8, () => {
4101
+ var _a;
3660
4102
  const position = positionSignal();
3661
4103
  const slot = activeSlot();
3662
4104
  let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
3663
- const states = checkStates();
4105
+ const states = checkStates(slot);
3664
4106
  if (slot) {
3665
4107
  const types = [
3666
4108
  [states.paragraph, jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" })],
@@ -3684,15 +4126,20 @@ const LeftToolbar = core.withAnnotation({
3684
4126
  }
3685
4127
  }
3686
4128
  }
4129
+ const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
4130
+ const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
3687
4131
  return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
3688
4132
  left: position.left + 'px',
3689
4133
  top: position.top + 'px',
3690
- display: position.display && selection.isCollapsed ? 'block' : 'none'
3691
- }, children: jsxRuntime.jsx(Dropdown, { abreast: true, style: {
4134
+ display: position.display && selection.isCollapsed && editorService.canShowLeftToolbar ? 'block' : 'none'
4135
+ }, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
3692
4136
  position: 'absolute',
3693
4137
  right: 0,
3694
4138
  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() ?
4139
+ }, menu: isEmptyBlock() ?
4140
+ jsxRuntime.jsx(InsertTool, { replace: !needInsert, slot: activeSlot() })
4141
+ :
4142
+ 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, slot: slot, applyBefore: applyBefore, 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, 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, { hideTitle: true, 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
4143
  jsxRuntime.jsx("span", { children: jsxRuntime.jsx("i", { class: "xnote-icon-plus" }) })
3697
4144
  :
3698
4145
  jsxRuntime.jsxs("span", { children: [activeNode, jsxRuntime.jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
@@ -3701,12 +4148,7 @@ const LeftToolbar = core.withAnnotation({
3701
4148
 
3702
4149
  class LeftToolbarPlugin {
3703
4150
  constructor() {
3704
- Object.defineProperty(this, "app", {
3705
- enumerable: true,
3706
- configurable: true,
3707
- writable: true,
3708
- value: null
3709
- });
4151
+ this.app = null;
3710
4152
  }
3711
4153
  setup(injector) {
3712
4154
  const App = function () {
@@ -3721,7 +4163,7 @@ class LeftToolbarPlugin {
3721
4163
  nativeRenderer: new platformBrowser$1.DomRenderer(),
3722
4164
  autoUpdate: true
3723
4165
  });
3724
- const viewDocument = injector.get(platformBrowser.VIEW_DOCUMENT);
4166
+ const viewDocument = injector.get(platformBrowser.VIEW_CONTAINER);
3725
4167
  const host = document.createElement('div');
3726
4168
  viewDocument.appendChild(host);
3727
4169
  this.app.mount(host);
@@ -3732,29 +4174,71 @@ class LeftToolbarPlugin {
3732
4174
  }
3733
4175
  }
3734
4176
 
3735
- var exportedId$6 = "vf-fee98b";
4177
+ var scopedId$7 = "vf-3073ba";
3736
4178
 
3737
- exports.EditorService = class EditorService {
3738
- constructor() {
3739
- Object.defineProperty(this, "hideInlineToolbar", {
3740
- enumerable: true,
3741
- configurable: true,
3742
- writable: true,
3743
- value: false
4179
+ function LinkJump() {
4180
+ const selection = core.inject(core$1.Selection);
4181
+ const query = core.inject(core$1.Query);
4182
+ const bridge = core.inject(platformBrowser.SelectionBridge);
4183
+ const container = core.inject(platformBrowser.VIEW_CONTAINER);
4184
+ const href = core.createSignal('');
4185
+ const ref = core.createRef();
4186
+ const isShow = core.createSignal(false);
4187
+ function onSelectionChange() {
4188
+ if (selection.isCollapsed) {
4189
+ const queryState = query.queryFormat(linkFormatter);
4190
+ if (queryState.state === core$1.QueryStateType.Enabled) {
4191
+ const rect = bridge.getRect({
4192
+ slot: selection.startSlot,
4193
+ offset: selection.startOffset
4194
+ });
4195
+ if (rect) {
4196
+ const offsetRect = container.getBoundingClientRect();
4197
+ Object.assign(ref.current.style, {
4198
+ left: rect.left - offsetRect.left + 'px',
4199
+ top: rect.top - offsetRect.top + 'px'
4200
+ });
4201
+ isShow.set(true);
4202
+ let url = queryState.value.href;
4203
+ if (url.indexOf('://') < 0) {
4204
+ url = 'http://' + url;
4205
+ }
4206
+ href.set(url);
4207
+ return;
4208
+ }
4209
+ }
4210
+ }
4211
+ isShow.set(false);
4212
+ }
4213
+ selection.onChange.pipe(core$1.delay()).subscribe(() => {
4214
+ onSelectionChange();
4215
+ });
4216
+ function cleanLink() {
4217
+ const commonAncestorSlot = selection.commonAncestorSlot;
4218
+ const index = selection.focusOffset;
4219
+ const ranges = commonAncestorSlot.getFormatRangesByFormatter(linkFormatter, 0, commonAncestorSlot.length);
4220
+ ranges.forEach(range => {
4221
+ if (range.startIndex < index && range.endIndex >= index) {
4222
+ commonAncestorSlot.applyFormat(linkFormatter, {
4223
+ startIndex: range.startIndex,
4224
+ endIndex: range.endIndex,
4225
+ value: null
4226
+ });
4227
+ }
3744
4228
  });
3745
4229
  }
3746
- };
3747
- exports.EditorService = __decorate([
3748
- core.Injectable({
3749
- provideIn: 'root'
3750
- })
3751
- ], exports.EditorService);
4230
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$7, () => {
4231
+ return (jsxRuntime.jsxs("div", { ref: ref, class: "link-jump-plugin", style: { display: isShow() ? '' : 'none' }, children: [jsxRuntime.jsx("span", { onClick: cleanLink, children: "\u6E05\u9664" }), jsxRuntime.jsx("a", { target: "_blank", href: href(), children: "\u8DF3\u8F6C" })] }));
4232
+ }), container);
4233
+ }
4234
+
4235
+ var scopedId$6 = "vf-fee98b";
3752
4236
 
3753
4237
  const Toolbar = core.withAnnotation({
3754
4238
  providers: [exports.RefreshService]
3755
4239
  }, function Toolbar() {
3756
4240
  const selection = core.inject(core$1.Selection);
3757
- const viewDocument = core.inject(platformBrowser.VIEW_DOCUMENT);
4241
+ const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
3758
4242
  const bridge = core.inject(platformBrowser.SelectionBridge);
3759
4243
  const textbus = core.inject(core$1.Textbus);
3760
4244
  const editorService = core.inject(exports.EditorService);
@@ -3792,7 +4276,6 @@ const Toolbar = core.withAnnotation({
3792
4276
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
3793
4277
  selectionFocusRect.top - docRect.top - toolbarRect.height - 10;
3794
4278
  updateViewPosition(draft => {
3795
- draft.isHide = false;
3796
4279
  draft.transitionDuration = .15;
3797
4280
  draft.left = centerLeft - docRect.left;
3798
4281
  draft.top = top + 10;
@@ -3820,6 +4303,7 @@ const Toolbar = core.withAnnotation({
3820
4303
  }), core$1.map(getTop), core$1.delay(200)).subscribe((top) => {
3821
4304
  if (top !== null) {
3822
4305
  updateViewPosition(draft => {
4306
+ draft.isHide = false;
3823
4307
  draft.opacity = 1;
3824
4308
  draft.top = top;
3825
4309
  });
@@ -3838,16 +4322,16 @@ const Toolbar = core.withAnnotation({
3838
4322
  });
3839
4323
  bindMouseup();
3840
4324
  });
4325
+ const instance = core.getCurrentInstance();
3841
4326
  function hideToolbar() {
3842
- updateViewPosition(draft => {
3843
- draft.isHide = true;
3844
- });
4327
+ editorService.hideInlineToolbar = true;
4328
+ instance.markAsDirtied();
3845
4329
  }
3846
4330
  core.onUnmounted(() => {
3847
4331
  mousedownSubscription.unsubscribe();
3848
4332
  mouseupSubscription.unsubscribe();
3849
4333
  });
3850
- return scopedCss.withScopedCSS(exportedId$6, () => {
4334
+ return scopedCss.withScopedCSS(scopedId$6, () => {
3851
4335
  const p = viewPosition();
3852
4336
  return (jsxRuntime.jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
3853
4337
  left: p.left + 'px',
@@ -3862,12 +4346,7 @@ const Toolbar = core.withAnnotation({
3862
4346
 
3863
4347
  class ToolbarPlugin {
3864
4348
  constructor() {
3865
- Object.defineProperty(this, "app", {
3866
- enumerable: true,
3867
- configurable: true,
3868
- writable: true,
3869
- value: null
3870
- });
4349
+ this.app = null;
3871
4350
  }
3872
4351
  setup(injector) {
3873
4352
  const App = function () {
@@ -3892,30 +4371,10 @@ class ToolbarPlugin {
3892
4371
 
3893
4372
  class Matcher {
3894
4373
  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
- });
4374
+ this.target = target;
4375
+ this.rule = rule;
4376
+ this.validators = [];
4377
+ this.excludeValidators = [];
3919
4378
  if (rule.tags) {
3920
4379
  this.validators.push(this.makeTagsMatcher(rule.tags));
3921
4380
  }
@@ -3993,63 +4452,235 @@ class Matcher {
3993
4452
  if (key === 'fontFamily' && typeof styleValue === 'string') {
3994
4453
  styleValue = styleValue.replace(/['"]/g, '');
3995
4454
  }
3996
- if (styleValue) {
3997
- return optionValue.map(v => {
3998
- if (v instanceof RegExp) {
3999
- return v.test(styleValue);
4000
- }
4001
- return v === styleValue;
4002
- }).includes(true);
4455
+ if (styleValue) {
4456
+ return optionValue.map(v => {
4457
+ if (v instanceof RegExp) {
4458
+ return v.test(styleValue);
4459
+ }
4460
+ return v === styleValue;
4461
+ }).includes(true);
4462
+ }
4463
+ return false;
4464
+ }).includes(false);
4465
+ };
4466
+ }
4467
+ }
4468
+
4469
+ class Organization {
4470
+ }
4471
+ function registerAtShortcut(textbus) {
4472
+ const keyboard = textbus.get(core$1.Keyboard);
4473
+ const selection = textbus.get(core$1.Selection);
4474
+ const commander = textbus.get(core$1.Commander);
4475
+ keyboard.addShortcut({
4476
+ keymap: {
4477
+ key: '@',
4478
+ shiftKey: true
4479
+ },
4480
+ action() {
4481
+ const { commonAncestorComponent } = selection;
4482
+ if (commonAncestorComponent instanceof SourceCodeComponent) {
4483
+ return false;
4484
+ }
4485
+ const at = new AtComponent(textbus);
4486
+ commander.insert(at);
4487
+ selection.setPosition(at.state.slot, 0);
4488
+ }
4489
+ });
4490
+ }
4491
+ class AtComponent extends core$1.Component {
4492
+ static fromJSON(textbus, { slot: slotState, userInfo }) {
4493
+ const registry = textbus.get(core$1.Registry);
4494
+ if (slotState) {
4495
+ const slot = registry.createSlot(slotState);
4496
+ return new AtComponent({
4497
+ slot
4498
+ });
4499
+ }
4500
+ return new AtComponent(textbus, {
4501
+ userInfo,
4502
+ });
4503
+ }
4504
+ constructor(textbus, state = {
4505
+ slot: new core$1.Slot([core$1.ContentType.Text])
4506
+ }) {
4507
+ if (!state.userInfo && !state.slot) {
4508
+ state.slot = new core$1.Slot([core$1.ContentType.Text]);
4509
+ }
4510
+ super(textbus, state);
4511
+ this.focus = new core$1.Subject();
4512
+ this.members = core.createSignal([]);
4513
+ this.selectedIndex = core.createSignal(0);
4514
+ }
4515
+ setup() {
4516
+ let isFocus = false;
4517
+ core$1.onFocus(() => {
4518
+ isFocus = true;
4519
+ this.focus.next(true);
4520
+ onChange.next();
4521
+ });
4522
+ core$1.onBlur(() => {
4523
+ isFocus = false;
4524
+ this.focus.next(false);
4525
+ setTimeout(() => {
4526
+ if (this.parent && !this.state.userInfo) {
4527
+ const slot = this.state.slot;
4528
+ let text = '@';
4529
+ if (slot) {
4530
+ text += slot.isEmpty ? '' : slot.toString();
4531
+ }
4532
+ const snapshot = selection.createSnapshot();
4533
+ selection.selectComponent(this);
4534
+ commander.insert(text);
4535
+ snapshot.restore(true);
4536
+ }
4537
+ });
4538
+ });
4539
+ const organization = core$1.useContext(Organization);
4540
+ const selection = core$1.useContext(core$1.Selection);
4541
+ const commander = core$1.useContext(core$1.Commander);
4542
+ const onChange = new core$1.Subject();
4543
+ core$1.onContentInserted((ev) => {
4544
+ const key = this.state.slot.toString();
4545
+ if (key.length > 10) {
4546
+ selection.selectComponent(this);
4547
+ commander.insert(key);
4548
+ ev.preventDefault();
4549
+ return;
4550
+ }
4551
+ onChange.next();
4552
+ });
4553
+ core$1.onContentDeleted(() => {
4554
+ onChange.next();
4555
+ });
4556
+ core$1.onBreak((ev) => {
4557
+ const member = this.members()[this.selectedIndex()];
4558
+ if (member) {
4559
+ this.state.userInfo = Object.assign({}, member);
4560
+ }
4561
+ selection.selectComponentEnd(this);
4562
+ ev.preventDefault();
4563
+ });
4564
+ core$1.useDynamicShortcut({
4565
+ keymap: {
4566
+ key: ['ArrowDown', 'ArrowUp']
4567
+ },
4568
+ action: (key) => {
4569
+ let index = this.selectedIndex();
4570
+ if (key === 'ArrowUp') {
4571
+ if (index > 0) {
4572
+ index--;
4573
+ this.selectedIndex.set(index);
4574
+ }
4575
+ return;
4576
+ }
4577
+ if (index < this.members().length - 1) {
4578
+ index++;
4579
+ this.selectedIndex.set(index);
4003
4580
  }
4004
- return false;
4005
- }).includes(false);
4006
- };
4581
+ }
4582
+ });
4583
+ const subs = onChange.pipe(core$1.switchMap(() => {
4584
+ const key = this.state.slot.toString();
4585
+ return core$1.fromPromise(organization.getMembers(key));
4586
+ })).subscribe((members) => {
4587
+ this.members.set(members);
4588
+ this.selectedIndex.set(0);
4589
+ if (isFocus) {
4590
+ this.focus.next(true);
4591
+ }
4592
+ });
4593
+ core$1.onDestroy(() => {
4594
+ subs.unsubscribe();
4595
+ });
4007
4596
  }
4008
4597
  }
4598
+ AtComponent.componentName = 'AtComponent';
4599
+ AtComponent.type = core$1.ContentType.InlineComponent;
4009
4600
 
4010
- class ImageComponent extends core$1.Component {
4011
- static fromJSON(textbus, json) {
4012
- return new ImageComponent(textbus, Object.assign({}, json));
4013
- }
4014
- }
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
- });
4027
- function ImageView(props) {
4028
- const { name, state } = props.component;
4029
- const imageRef = core.createRef();
4601
+ function AtComponentView(props) {
4602
+ const adapter = core.inject(platformBrowser.DomAdapter);
4603
+ const selection = core.inject(core$1.Selection);
4604
+ const dropdownRef = core.createRef();
4605
+ const subscription = props.component.focus.subscribe((b) => {
4606
+ if (dropdownRef.current && props.component.members().length) {
4607
+ dropdownRef.current.isShow(b);
4608
+ }
4609
+ });
4610
+ core.onUnmounted(() => {
4611
+ subscription.unsubscribe();
4612
+ });
4030
4613
  const readonly = useReadonly();
4031
4614
  const output = useOutput();
4615
+ const membersRef = core.createRef();
4616
+ core.onUpdated(() => {
4617
+ if (output() || readonly()) {
4618
+ return;
4619
+ }
4620
+ const container = membersRef.current;
4621
+ if (container) {
4622
+ const focusItem = container.children[props.component.selectedIndex()];
4623
+ if (focusItem) {
4624
+ const itemRect = focusItem.getBoundingClientRect();
4625
+ const dropdownMenu = container.parentNode.parentNode;
4626
+ const containerRect = dropdownMenu.getBoundingClientRect();
4627
+ if (itemRect.top - 5 < containerRect.top) {
4628
+ dropdownMenu.scrollTop += itemRect.top - 5 - containerRect.top;
4629
+ }
4630
+ else if (itemRect.bottom + 5 > containerRect.bottom) {
4631
+ dropdownMenu.scrollTop += itemRect.bottom + 5 - containerRect.bottom;
4632
+ }
4633
+ }
4634
+ }
4635
+ });
4032
4636
  return () => {
4637
+ const { slot, userInfo } = props.component.state;
4638
+ const selectedIndex = props.component.selectedIndex();
4639
+ if (userInfo) {
4640
+ return (jsxRuntime.jsxs("div", { class: "xnote-at xnote-at-complete", "data-info": encodeURIComponent(JSON.stringify(userInfo)), ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), userInfo.name] }));
4641
+ }
4033
4642
  if (readonly() || output()) {
4034
- return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
4035
- width: state.width,
4036
- height: state.height
4037
- } }) }));
4643
+ return (jsxRuntime.jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4644
+ return core$1.createVNode('span', {
4645
+ class: 'xnote-at-input'
4646
+ }, children);
4647
+ })] }));
4038
4648
  }
4039
- return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx(DragResize, { source: imageRef, component: props.component, children: jsxRuntime.jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
4040
- width: state.width,
4041
- height: state.height
4042
- } }) }) }));
4649
+ const members = props.component.members();
4650
+ return (jsxRuntime.jsx("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsxs(Dropdown, { trigger: 'none', ref: dropdownRef, menu: jsxRuntime.jsx("div", { class: "xnote-at-menu", ref: membersRef, children: members.map((member, index) => {
4651
+ let hsl = color.any2Hsl(member.color);
4652
+ if (hsl === 'unknown') {
4653
+ hsl = color.any2Hsl('#000');
4654
+ }
4655
+ const rgb = color.hsl2Rgb(hsl);
4656
+ const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
4657
+ const color$1 = yiq >= 128 ? '#000' : '#fff';
4658
+ return (jsxRuntime.jsxs("div", { onClick: () => {
4659
+ props.component.state.userInfo = member;
4660
+ selection.selectComponentEnd(props.component);
4661
+ }, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsxRuntime.jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsxRuntime.jsx("img", { src: member.avatar, alt: member.name }) :
4662
+ jsxRuntime.jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color: color$1 }, children: member.name }) }), jsxRuntime.jsxs("div", { class: "xnote-at-member-info", children: [jsxRuntime.jsx("div", { class: "xnote-at-member-name", children: member.name }), jsxRuntime.jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
4663
+ }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && adapter.slotRender(slot, children => {
4664
+ return core$1.createVNode('span', {
4665
+ class: 'xnote-at-input'
4666
+ }, children);
4667
+ })] }) }));
4043
4668
  };
4044
4669
  }
4045
- const imageComponentLoader = {
4670
+ const atComponentLoader = {
4046
4671
  match(element) {
4047
- return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
4672
+ return element.dataset.component === AtComponent.componentName;
4048
4673
  },
4049
- read(element, textbus) {
4050
- var _a;
4051
- return new ImageComponent(textbus, {
4052
- src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('img')) === null || _a === void 0 ? void 0 : _a.src) || ''
4674
+ read(element, textbus, slotParser) {
4675
+ const data = element.dataset.info;
4676
+ if (data) {
4677
+ return new AtComponent(textbus, {
4678
+ userInfo: JSON.parse(decodeURIComponent(data))
4679
+ });
4680
+ }
4681
+ const slot = slotParser(new core$1.Slot([core$1.ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
4682
+ return new AtComponent(textbus, {
4683
+ slot
4053
4684
  });
4054
4685
  }
4055
4686
  };
@@ -4057,38 +4688,16 @@ const imageComponentLoader = {
4057
4688
  class RootComponent extends core$1.Component {
4058
4689
  constructor() {
4059
4690
  super(...arguments);
4060
- Object.defineProperty(this, "onCompositionStart", {
4061
- enumerable: true,
4062
- configurable: true,
4063
- writable: true,
4064
- value: new core$1.Subject()
4065
- });
4691
+ this.onCompositionStart = new core$1.Subject();
4066
4692
  }
4067
4693
  static fromJSON(textbus, json) {
4068
- const heading = textbus.get(core$1.Registry).createSlot(json.heading);
4069
4694
  const content = textbus.get(core$1.Registry).createSlot(json.content);
4070
4695
  return new RootComponent(textbus, {
4071
- heading,
4072
4696
  content
4073
4697
  });
4074
4698
  }
4075
4699
  setup() {
4076
- const textbus = core$1.useContext();
4077
- const selection = textbus.get(core$1.Selection);
4078
- core$1.onBreak(ev => {
4079
- if (ev.target === this.state.heading) {
4080
- const afterContent = ev.target.cut(ev.data.index);
4081
- const p = new ParagraphComponent(textbus, {
4082
- slot: afterContent
4083
- });
4084
- const body = this.state.content;
4085
- body.retain(0);
4086
- body.insert(p);
4087
- selection.setPosition(afterContent, 0);
4088
- ev.preventDefault();
4089
- }
4090
- });
4091
- useBlockContent(this.state.content);
4700
+ useBlockContent((slot) => slot === this.state.content);
4092
4701
  core$1.onCompositionStart(ev => {
4093
4702
  this.onCompositionStart.next(ev);
4094
4703
  });
@@ -4105,29 +4714,14 @@ class RootComponent extends core$1.Component {
4105
4714
  content.insert(new ParagraphComponent(this.textbus));
4106
4715
  }
4107
4716
  }
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
- });
4717
+ RootComponent.componentName = 'RootComponent';
4718
+ RootComponent.type = core$1.ContentType.BlockComponent;
4120
4719
  function RootView(props) {
4121
4720
  const adapter = core.inject(platformBrowser.DomAdapter);
4122
- const { heading, content } = props.component.state;
4721
+ const { content } = props.component.state;
4123
4722
  const ref = core.createDynamicRef(node => {
4124
- const sub = props.component.onCompositionStart.subscribe(ev => {
4125
- if (ev.target === heading) {
4126
- node.children[0].dataset.placeholder = '';
4127
- }
4128
- else {
4129
- node.children[1].dataset.placeholder = '';
4130
- }
4723
+ const sub = props.component.onCompositionStart.subscribe(() => {
4724
+ node.children[0].dataset.placeholder = '';
4131
4725
  });
4132
4726
  return () => {
4133
4727
  sub.unsubscribe();
@@ -4137,19 +4731,15 @@ function RootView(props) {
4137
4731
  props.component.afterCheck();
4138
4732
  });
4139
4733
  const readonly = useReadonly();
4734
+ const output = useOutput();
4140
4735
  return () => {
4141
4736
  const { rootRef } = props;
4142
- return (jsxRuntime.jsxs("div", { class: "xnote-root", ref: [rootRef, ref], children: [adapter.slotRender(heading, children => {
4143
- return (core$1.createVNode('div', {
4144
- class: 'xnote-title',
4145
- 'data-placeholder': heading.isEmpty ? '请输入标题' : ''
4146
- }, children));
4147
- }, readonly()), adapter.slotRender(content, children => {
4148
- return (core$1.createVNode('div', {
4149
- class: 'xnote-content',
4150
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4151
- }, children));
4152
- }, readonly())] }));
4737
+ return (jsxRuntime.jsx("div", { class: "xnote-root", ref: [rootRef, ref], "data-comopnent": props.component.name, children: adapter.slotRender(content, children => {
4738
+ return (core$1.createVNode('div', {
4739
+ class: 'xnote-content',
4740
+ 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4741
+ }, children));
4742
+ }, readonly() || output()) }));
4153
4743
  };
4154
4744
  }
4155
4745
  const rootComponentLoader = {
@@ -4163,9 +4753,7 @@ const rootComponentLoader = {
4163
4753
  core$1.ContentType.Text
4164
4754
  ]), element).toDelta();
4165
4755
  const slot = new core$1.Slot([
4166
- core$1.ContentType.BlockComponent,
4167
- core$1.ContentType.InlineComponent,
4168
- core$1.ContentType.Text
4756
+ core$1.ContentType.BlockComponent
4169
4757
  ]);
4170
4758
  deltaToBlock(delta, textbus).forEach(i => {
4171
4759
  slot.insert(i);
@@ -4174,40 +4762,15 @@ const rootComponentLoader = {
4174
4762
  }
4175
4763
  };
4176
4764
 
4177
- var exportedId$5 = "vf-681de2";
4765
+ var scopedId$5 = "vf-681de2";
4178
4766
 
4179
4767
  let TableService = class TableService {
4180
4768
  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
- });
4769
+ this.onInsertRowBefore = new core$1.Subject();
4770
+ this.onInsertColumnBefore = new core$1.Subject();
4771
+ this.onSelectColumns = new core$1.Subject();
4772
+ this.onSelectRows = new core$1.Subject();
4773
+ this.onScroll = new core$1.Subject();
4211
4774
  }
4212
4775
  };
4213
4776
  TableService = __decorate([
@@ -4217,6 +4780,7 @@ TableService = __decorate([
4217
4780
  function ResizeColumn(props) {
4218
4781
  const dragLineRef = core.createRef();
4219
4782
  let activeCol = null;
4783
+ const editorService = core.inject(exports.EditorService);
4220
4784
  core.onMounted(() => {
4221
4785
  const { tableRef } = props;
4222
4786
  let isDrag = false;
@@ -4249,6 +4813,7 @@ function ResizeColumn(props) {
4249
4813
  }
4250
4814
  })).add(core$1.fromEvent(dragLineRef.current, 'mousedown').subscribe(downEvent => {
4251
4815
  isDrag = true;
4816
+ editorService.changeLeftToolbarVisible(false);
4252
4817
  props.onActiveStateChange(true);
4253
4818
  const x = downEvent.clientX;
4254
4819
  const layoutWidth = props.component.state.layoutWidth;
@@ -4256,16 +4821,20 @@ function ResizeColumn(props) {
4256
4821
  const initLeft = layoutWidth.slice(0, activeCol).reduce((a, b) => a + b, 0);
4257
4822
  const minWidth = 30;
4258
4823
  const minLeft = initLeft - initWidth + minWidth;
4824
+ const layoutWidthArr = layoutWidth.slice();
4259
4825
  const moveEvent = core$1.fromEvent(document, 'mousemove').subscribe(moveEvent => {
4260
4826
  const distanceX = moveEvent.clientX - x;
4261
4827
  dragLineRef.current.style.left = Math.max(initLeft + distanceX, minLeft) + 'px';
4262
- props.component.state.layoutWidth[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
4828
+ layoutWidthArr[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
4829
+ props.layoutWidth.set(layoutWidthArr.slice());
4263
4830
  }).add(core$1.fromEvent(document, 'mouseup').subscribe(upEvent => {
4264
4831
  isDrag = false;
4832
+ editorService.changeLeftToolbarVisible(true);
4265
4833
  props.onActiveStateChange(false);
4266
4834
  moveEvent.unsubscribe();
4267
4835
  const distanceX = upEvent.clientX - x;
4268
4836
  props.component.state.layoutWidth[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
4837
+ props.layoutWidth.set(props.component.state.layoutWidth);
4269
4838
  }));
4270
4839
  }));
4271
4840
  return () => {
@@ -4286,12 +4855,12 @@ function ResizeColumn(props) {
4286
4855
  });
4287
4856
  return () => sub.unsubscribe();
4288
4857
  });
4289
- return scopedCss.withScopedCSS(exportedId$5, () => {
4858
+ return scopedCss.withScopedCSS(scopedId$5, () => {
4290
4859
  return jsxRuntime.jsx("div", { ref: dragLineRef, class: ['drag-line'] });
4291
4860
  });
4292
4861
  }
4293
4862
 
4294
- var exportedId$4 = "vf-5bce97";
4863
+ var scopedId$4 = "vf-39cb2c";
4295
4864
 
4296
4865
  function TopBar(props) {
4297
4866
  const editorService = core.inject(exports.EditorService);
@@ -4359,14 +4928,14 @@ function TopBar(props) {
4359
4928
  s.unsubscribe();
4360
4929
  });
4361
4930
  const deleteIndex = core.createSignal(null);
4362
- return scopedCss.withScopedCSS(exportedId$4, () => {
4931
+ return scopedCss.withScopedCSS(scopedId$4, () => {
4363
4932
  const { state, tableSelection } = props.component;
4364
4933
  const position = tableSelection();
4365
4934
  return (jsxRuntime.jsx("div", { class: ['top-bar', {
4366
4935
  active: props.isFocus()
4367
4936
  }], children: jsxRuntime.jsxs("div", { class: "toolbar-wrapper", children: [jsxRuntime.jsx("div", { class: "insert-bar", children: jsxRuntime.jsx("table", { style: {
4368
4937
  transform: `translateX(${-leftDistance()}px)`
4369
- }, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: state.layoutWidth.map((i, index) => {
4938
+ }, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
4370
4939
  return (jsxRuntime.jsx("td", { style: { width: i + 'px', minWidth: i + 'px' }, children: jsxRuntime.jsxs("div", { class: "tool-container", children: [index === 0 && (jsxRuntime.jsx("span", { onMouseenter: () => {
4371
4940
  tableService.onInsertColumnBefore.next(0);
4372
4941
  }, onMouseleave: () => {
@@ -4392,7 +4961,7 @@ function TopBar(props) {
4392
4961
  }, children: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }) }) }) })] }) }));
4393
4962
  }) }) }) }) }), jsxRuntime.jsx("div", { class: ['action-bar', { active: props.isFocus() }], children: jsxRuntime.jsx("table", { style: {
4394
4963
  transform: `translateX(${-leftDistance()}px)`
4395
- }, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: state.layoutWidth.map((i, index) => {
4964
+ }, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
4396
4965
  return jsxRuntime.jsx("td", { onClick: ev => {
4397
4966
  mouseDownFromToolbar = true;
4398
4967
  if (!ev.shiftKey) {
@@ -4412,7 +4981,7 @@ function TopBar(props) {
4412
4981
  });
4413
4982
  }
4414
4983
 
4415
- var exportedId$3 = "vf-b1149b";
4984
+ var scopedId$3 = "vf-c3d159";
4416
4985
 
4417
4986
  function Scroll(props) {
4418
4987
  const scrollRef = core.createRef();
@@ -4426,7 +4995,7 @@ function Scroll(props) {
4426
4995
  const el = scrollRef.current;
4427
4996
  function update() {
4428
4997
  if (props.isFocus()) {
4429
- input.caret.refresh(false);
4998
+ input.caret.refresh();
4430
4999
  }
4431
5000
  updateShowShadow(draft => {
4432
5001
  draft.leftEnd = el.scrollLeft === 0;
@@ -4444,7 +5013,7 @@ function Scroll(props) {
4444
5013
  draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
4445
5014
  });
4446
5015
  });
4447
- return scopedCss.withScopedCSS(exportedId$3, () => {
5016
+ return scopedCss.withScopedCSS(scopedId$3, () => {
4448
5017
  return jsxRuntime.jsx("div", { ref: [scrollRef, props.scrollRef], class: ['scroll-container', {
4449
5018
  'left-end': showShadow().leftEnd,
4450
5019
  'right-end': showShadow().rightEnd,
@@ -4456,7 +5025,7 @@ function Scroll(props) {
4456
5025
  });
4457
5026
  }
4458
5027
 
4459
- var exportedId$2 = "vf-ef93c0";
5028
+ var scopedId$2 = "vf-aaece0";
4460
5029
 
4461
5030
  function LeftBar(props) {
4462
5031
  const editorService = core.inject(exports.EditorService);
@@ -4530,7 +5099,7 @@ function LeftBar(props) {
4530
5099
  textbus.focus();
4531
5100
  });
4532
5101
  }
4533
- return scopedCss.withScopedCSS(exportedId$2, () => {
5102
+ return scopedCss.withScopedCSS(scopedId$2, () => {
4534
5103
  const { state, tableSelection } = props.component;
4535
5104
  const position = tableSelection();
4536
5105
  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 +5147,7 @@ function LeftBar(props) {
4578
5147
  });
4579
5148
  }
4580
5149
 
4581
- var exportedId$1 = "vf-d4c4a9";
5150
+ var scopedId$1 = "vf-d4c4a9";
4582
5151
 
4583
5152
  function sum(numbers) {
4584
5153
  return numbers.reduce((a, b) => a + b, 0);
@@ -4611,7 +5180,7 @@ function ResizeRow(props) {
4611
5180
  });
4612
5181
  return () => sub.unsubscribe();
4613
5182
  });
4614
- return scopedCss.withScopedCSS(exportedId$1, () => {
5183
+ return scopedCss.withScopedCSS(scopedId$1, () => {
4615
5184
  return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
4616
5185
  display: styles().visible ? 'block' : 'none',
4617
5186
  top: styles().top + 'px',
@@ -4620,7 +5189,7 @@ function ResizeRow(props) {
4620
5189
  });
4621
5190
  }
4622
5191
 
4623
- var exportedId = "vf-e16878";
5192
+ var scopedId = "vf-4a5ad1";
4624
5193
 
4625
5194
  function SelectionMask(props) {
4626
5195
  const [styles, updateStyles] = hooks.useProduce({
@@ -4673,7 +5242,7 @@ function SelectionMask(props) {
4673
5242
  core.onUnmounted(() => {
4674
5243
  s.unsubscribe();
4675
5244
  });
4676
- return scopedCss.withScopedCSS(exportedId, () => {
5245
+ return scopedCss.withScopedCSS(scopedId, () => {
4677
5246
  const style = styles();
4678
5247
  return (jsxRuntime.jsx("div", { class: "mask", style: {
4679
5248
  display: style.visible ? 'block' : 'none',
@@ -4691,9 +5260,14 @@ const TableComponentView = core.withAnnotation({
4691
5260
  providers: [TableService]
4692
5261
  }, function TableComponentView(props) {
4693
5262
  const adapter = core.inject(platformBrowser.DomAdapter);
5263
+ const editorService = core.inject(exports.EditorService);
4694
5264
  const isFocus = core.createSignal(false);
5265
+ const layoutWidth = core.createSignal(props.component.state.layoutWidth);
4695
5266
  const subscription = props.component.focus.subscribe(b => {
4696
5267
  isFocus.set(b);
5268
+ if (!b) {
5269
+ editorService.hideInlineToolbar = false;
5270
+ }
4697
5271
  });
4698
5272
  core.onUnmounted(() => {
4699
5273
  subscription.unsubscribe();
@@ -4701,67 +5275,6 @@ const TableComponentView = core.withAnnotation({
4701
5275
  const tableRef = core.createRef();
4702
5276
  const scrollRef = core.createRef();
4703
5277
  const isResizeColumn = core.createSignal(false);
4704
- const selection = core.inject(core$1.Selection);
4705
- const findPosition = (slot) => {
4706
- let cell = slot;
4707
- while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== props.component) {
4708
- cell = cell.parentSlot;
4709
- }
4710
- if (cell) {
4711
- const rows = props.component.state.rows;
4712
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
4713
- const row = rows[rowIndex].cells;
4714
- for (let colIndex = 0; colIndex < row.length; colIndex++) {
4715
- const item = row[colIndex].slot;
4716
- if (item === cell) {
4717
- return {
4718
- rowIndex,
4719
- colIndex
4720
- };
4721
- }
4722
- }
4723
- }
4724
- }
4725
- return null;
4726
- };
4727
- core.onMounted(() => {
4728
- const sub = selection.onChange.subscribe(() => {
4729
- var _a;
4730
- if (selection.commonAncestorComponent !== props.component || selection.isCollapsed) {
4731
- props.component.tableSelection.set(null);
4732
- return;
4733
- }
4734
- const startPosition = findPosition(selection.startSlot);
4735
- const endPosition = findPosition(selection.endSlot);
4736
- if (startPosition && endPosition) {
4737
- if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
4738
- if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
4739
- props.component.tableSelection.set({
4740
- startColumn: startPosition.colIndex,
4741
- startRow: startPosition.rowIndex,
4742
- endColumn: endPosition.colIndex + 1,
4743
- endRow: endPosition.rowIndex + 1
4744
- });
4745
- return;
4746
- }
4747
- props.component.tableSelection.set(null);
4748
- return;
4749
- }
4750
- const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
4751
- const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
4752
- props.component.tableSelection.set({
4753
- startColumn,
4754
- startRow,
4755
- endColumn: endColumn + 1,
4756
- endRow: endRow + 1
4757
- });
4758
- }
4759
- else {
4760
- props.component.tableSelection.set(null);
4761
- }
4762
- });
4763
- return () => sub.unsubscribe();
4764
- });
4765
5278
  const rowMapping = new WeakMap();
4766
5279
  const readonly = useReadonly();
4767
5280
  const output = useOutput();
@@ -4774,45 +5287,42 @@ const TableComponentView = core.withAnnotation({
4774
5287
  }
4775
5288
  rowMapping.set(row, Math.random());
4776
5289
  });
4777
- Promise.resolve().then(() => {
4778
- props.component.afterContentCheck();
4779
- });
4780
5290
  if (readonly() || output()) {
4781
- return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
4782
- 'xnote-table-content',
4783
- {
4784
- 'hide-selection': props.component.tableSelection()
4785
- }
4786
- ], children: [jsxRuntime.jsx("colgroup", { children: state.layoutWidth.map(w => {
4787
- return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
4788
- }) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
4789
- return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
4790
- return adapter.slotRender(cell.slot, children => {
4791
- return core$1.createVNode('td', {
4792
- key: cell.slot.id
4793
- }, children);
4794
- }, readonly());
4795
- }) }, rowMapping.get(row)));
4796
- }) })] }) }) }));
4797
- }
4798
- return (jsxRuntime.jsxs("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, component: props.component, scrollRef: scrollRef }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { scrollRef: scrollRef, isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
4799
- 'xnote-table-content',
4800
- {
4801
- 'hide-selection': props.component.tableSelection()
4802
- }
4803
- ], children: [jsxRuntime.jsx("colgroup", { children: state.layoutWidth.map(w => {
4804
- return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
4805
- }) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
4806
- return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
4807
- return adapter.slotRender(cell.slot, children => {
4808
- return core$1.createVNode('td', {
4809
- key: cell.slot.id
4810
- }, children);
4811
- }, readonly());
4812
- }) }, rowMapping.get(row)));
4813
- }) })] }), jsxRuntime.jsx(ResizeColumn, { tableRef: tableRef, component: props.component, onActiveStateChange: isActive => {
4814
- isResizeColumn.set(isActive);
4815
- } }), jsxRuntime.jsx(SelectionMask, { tableRef: tableRef, component: props.component })] }) }), jsxRuntime.jsx(ResizeRow, { component: props.component, tableRef: tableRef })] }));
5291
+ return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
5292
+ 'xnote-table-content',
5293
+ {
5294
+ 'hide-selection': props.component.tableSelection()
5295
+ }
5296
+ ], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
5297
+ return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
5298
+ }) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
5299
+ return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
5300
+ return adapter.slotRender(cell.slot, children => {
5301
+ return core$1.createVNode('td', {
5302
+ key: cell.slot.id
5303
+ }, children);
5304
+ }, readonly() || output());
5305
+ }) }, rowMapping.get(row)));
5306
+ }) })] }) }) }) }));
5307
+ }
5308
+ return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component, scrollRef: scrollRef }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { scrollRef: scrollRef, isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
5309
+ 'xnote-table-content',
5310
+ {
5311
+ 'hide-selection': props.component.tableSelection()
5312
+ }
5313
+ ], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
5314
+ return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
5315
+ }) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
5316
+ return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
5317
+ return adapter.slotRender(cell.slot, children => {
5318
+ return core$1.createVNode('td', {
5319
+ key: cell.slot.id
5320
+ }, children);
5321
+ }, readonly() || output());
5322
+ }) }, rowMapping.get(row)));
5323
+ }) })] }), jsxRuntime.jsx(ResizeColumn, { tableRef: tableRef, component: props.component, layoutWidth: layoutWidth, onActiveStateChange: isActive => {
5324
+ isResizeColumn.set(isActive);
5325
+ } }), jsxRuntime.jsx(SelectionMask, { tableRef: tableRef, component: props.component })] }) }), jsxRuntime.jsx(ResizeRow, { component: props.component, tableRef: tableRef })] }) }));
4816
5326
  };
4817
5327
  });
4818
5328
  const tableComponentLoader = {
@@ -4833,8 +5343,6 @@ const tableComponentLoader = {
4833
5343
  Array.from(row.cells).forEach(cell => {
4834
5344
  const slot = new core$1.Slot([
4835
5345
  core$1.ContentType.BlockComponent,
4836
- core$1.ContentType.InlineComponent,
4837
- core$1.ContentType.Text
4838
5346
  ]);
4839
5347
  arr.push({
4840
5348
  slot,
@@ -4862,8 +5370,6 @@ const tableComponentLoader = {
4862
5370
  Array.from(row.cells).forEach(cell => {
4863
5371
  const slot = new core$1.Slot([
4864
5372
  core$1.ContentType.BlockComponent,
4865
- core$1.ContentType.InlineComponent,
4866
- core$1.ContentType.Text
4867
5373
  ]);
4868
5374
  arr.push({
4869
5375
  slot,
@@ -4950,8 +5456,6 @@ function autoComplete(table) {
4950
5456
  rowspan: 1,
4951
5457
  colspan: 1,
4952
5458
  slot: new core$1.Slot([
4953
- core$1.ContentType.Text,
4954
- core$1.ContentType.InlineComponent,
4955
5459
  core$1.ContentType.BlockComponent
4956
5460
  ])
4957
5461
  };
@@ -4971,59 +5475,91 @@ function autoComplete(table) {
4971
5475
  });
4972
5476
  }
4973
5477
 
4974
- class VideoComponent extends core$1.Component {
4975
- static fromJSON(textbus, json) {
4976
- return new VideoComponent(textbus, Object.assign({}, json));
4977
- }
4978
- setup() {
4979
- //
5478
+ function findFocusCell(table, slot) {
5479
+ var _a;
5480
+ while (slot) {
5481
+ if (table.__slots__.includes(slot)) {
5482
+ return slot;
5483
+ }
5484
+ slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
4980
5485
  }
5486
+ return null;
4981
5487
  }
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
- });
4994
- function VideoView(props) {
4995
- const { name, state } = props.component;
4996
- const videoRef = core.createRef();
4997
- const readonly = useReadonly();
4998
- const output = useOutput();
4999
- return () => {
5000
- if (readonly() || output()) {
5001
- return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
5002
- width: state.width,
5003
- height: state.height
5004
- } }) }));
5488
+ let TableSelectionAwarenessDelegate = class TableSelectionAwarenessDelegate extends platformBrowser.CollaborateSelectionAwarenessDelegate {
5489
+ constructor(domAdapter, selection) {
5490
+ super();
5491
+ this.domAdapter = domAdapter;
5492
+ this.selection = selection;
5493
+ }
5494
+ getRects(abstractSelection) {
5495
+ const { focusSlot, anchorSlot } = abstractSelection;
5496
+ const focusPaths = this.selection.getPathsBySlot(focusSlot);
5497
+ const anchorPaths = this.selection.getPathsBySlot(anchorSlot);
5498
+ const focusIsStart = core$1.Selection.compareSelectionPaths(focusPaths, anchorPaths);
5499
+ let startSlot;
5500
+ let endSlot;
5501
+ if (focusIsStart) {
5502
+ startSlot = focusSlot;
5503
+ endSlot = anchorSlot;
5005
5504
  }
5006
- return (jsxRuntime.jsx("div", { ref: props.rootRef, class: "xnote-video", "data-component": name, children: jsxRuntime.jsx(DragResize, { source: videoRef, component: props.component, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
5007
- width: state.width,
5008
- height: state.height
5009
- } }) }) }));
5505
+ else {
5506
+ startSlot = anchorSlot;
5507
+ endSlot = focusSlot;
5508
+ }
5509
+ const commonAncestorComponent = core$1.Selection.getCommonAncestorComponent(startSlot, endSlot);
5510
+ if (!(commonAncestorComponent instanceof TableComponent)) {
5511
+ return false;
5512
+ }
5513
+ const range = getSelectedRanges(commonAncestorComponent, findFocusCell(commonAncestorComponent, startSlot), findFocusCell(commonAncestorComponent, endSlot));
5514
+ const rows = commonAncestorComponent.state.rows;
5515
+ const startFocusSlot = rows[range.startRow].cells[range.startColumn].slot;
5516
+ const endFocusSlot = rows[range.endRow].cells[range.endColumn].slot;
5517
+ const renderer = this.domAdapter;
5518
+ const startRect = renderer.getNativeNodeBySlot(startFocusSlot).getBoundingClientRect();
5519
+ const endRect = renderer.getNativeNodeBySlot(endFocusSlot).getBoundingClientRect();
5520
+ return [{
5521
+ left: startRect.left,
5522
+ top: startRect.top,
5523
+ width: endRect.left + endRect.width - startRect.left,
5524
+ height: endRect.top + endRect.height - startRect.top
5525
+ }];
5526
+ }
5527
+ };
5528
+ TableSelectionAwarenessDelegate = __decorate([
5529
+ core.Injectable(),
5530
+ __metadata("design:paramtypes", [platformBrowser.DomAdapter,
5531
+ core$1.Selection])
5532
+ ], TableSelectionAwarenessDelegate);
5533
+ function getSelectedRanges(component, startSlot, endSlot) {
5534
+ const p1 = finedPosition(component, startSlot);
5535
+ const p2 = finedPosition(component, endSlot);
5536
+ return {
5537
+ startRow: Math.min(p1.rowIndex, p2.rowIndex),
5538
+ endRow: Math.max(p1.rowIndex, p2.rowIndex),
5539
+ startColumn: Math.min(p1.columnIndex, p2.columnIndex),
5540
+ endColumn: Math.max(p1.columnIndex, p2.columnIndex)
5010
5541
  };
5011
5542
  }
5012
- const videoComponentLoader = {
5013
- match(element) {
5014
- return element.tagName === 'IMG' || element.dataset.component === VideoComponent.componentName;
5015
- },
5016
- read(element, textbus) {
5017
- var _a;
5018
- return new VideoComponent(textbus, {
5019
- src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('video')) === null || _a === void 0 ? void 0 : _a.src) || ''
5020
- });
5543
+ function finedPosition(component, slot) {
5544
+ const rows = component.state.rows;
5545
+ for (let i = 0; i < rows.length; i++) {
5546
+ const row = rows[i];
5547
+ for (let j = 0; j < row.cells.length; j++) {
5548
+ const cell = row.cells[j].slot;
5549
+ if (cell === slot) {
5550
+ return {
5551
+ rowIndex: i,
5552
+ columnIndex: j
5553
+ };
5554
+ }
5555
+ }
5021
5556
  }
5022
- };
5557
+ return null;
5558
+ }
5023
5559
 
5024
- function createXNote(host, config = {}) {
5025
- return __awaiter(this, void 0, void 0, function* () {
5026
- const adapter = new adapterViewfly.Adapter({
5560
+ class Editor extends core$1.Textbus {
5561
+ constructor(editorConfig = {}) {
5562
+ const adapter = new adapterViewfly.ViewflyAdapter({
5027
5563
  [ParagraphComponent.componentName]: ParagraphView,
5028
5564
  [RootComponent.componentName]: RootView,
5029
5565
  [BlockquoteComponent.componentName]: BlockquoteView,
@@ -5033,36 +5569,36 @@ function createXNote(host, config = {}) {
5033
5569
  [HighlightBoxComponent.componentName]: HighlightBoxView,
5034
5570
  [ListComponent.componentName]: ListComponentView,
5035
5571
  [ImageComponent.componentName]: ImageView,
5036
- [VideoComponent.componentName]: VideoView
5037
- }, (host, root) => {
5038
- const appInjector = new core.ReflectiveInjector(textbus, [{
5572
+ [VideoComponent.componentName]: VideoView,
5573
+ [AtComponent.componentName]: AtComponentView,
5574
+ [KatexComponent.componentName]: KatexComponentView,
5575
+ }, (host, root, injector) => {
5576
+ const appInjector = new core.ReflectiveInjector(injector, [{
5039
5577
  provide: OutputInjectionToken,
5040
5578
  useValue: false
5041
5579
  }]);
5042
- const app = platformBrowser$1.createApp(root, {
5580
+ const app = platformBrowser$1.createApp(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [root, jsxRuntime.jsx(LinkJump, {})] }), {
5043
5581
  context: appInjector
5044
5582
  }).mount(host);
5045
5583
  return () => {
5046
5584
  app.destroy();
5047
5585
  };
5048
5586
  });
5049
- const browserModule = new platformBrowser.BrowserModule({
5050
- renderTo() {
5051
- return host;
5052
- },
5053
- adapter,
5054
- componentLoaders: [
5055
- highlightBoxComponentLoader,
5056
- blockquoteComponentLoader,
5057
- paragraphComponentLoader,
5587
+ const browserModule = new platformBrowser.BrowserModule(Object.assign({ renderTo: () => {
5588
+ return this.host;
5589
+ }, useContentEditable: platformBrowser.isMobileBrowser(), adapter, componentLoaders: [
5590
+ atComponentLoader,
5058
5591
  sourceCodeComponentLoader,
5059
- todolistComponentLoader,
5060
- tableComponentLoader,
5061
5592
  listComponentLoader,
5593
+ tableComponentLoader,
5062
5594
  imageComponentLoader,
5063
- videoComponentLoader
5064
- ],
5065
- formatLoaders: [
5595
+ highlightBoxComponentLoader,
5596
+ blockquoteComponentLoader,
5597
+ videoComponentLoader,
5598
+ todolistComponentLoader,
5599
+ katexComponentLoader,
5600
+ paragraphComponentLoader,
5601
+ ], formatLoaders: [
5066
5602
  backgroundColorFormatLoader,
5067
5603
  boldFormatLoader,
5068
5604
  codeFormatLoader,
@@ -5073,22 +5609,51 @@ function createXNote(host, config = {}) {
5073
5609
  linkFormatLoader,
5074
5610
  strikeThroughFormatLoader,
5075
5611
  underlineFormatLoader
5076
- ],
5077
- attributeLoaders: [
5612
+ ], attributeLoaders: [
5078
5613
  headingAttrLoader,
5079
5614
  textAlignAttrLoader,
5080
5615
  textIndentAttrLoader
5081
- ]
5082
- });
5616
+ ] }, editorConfig.viewOptions));
5083
5617
  const modules = [browserModule];
5084
- if (config.collaborateConfig) {
5085
- modules.push(new collaborate.CollaborateModule(config.collaborateConfig));
5618
+ if (editorConfig.collaborateConfig) {
5619
+ modules.push(new collaborate.CollaborateModule(editorConfig.collaborateConfig));
5620
+ browserModule.providers.push({
5621
+ provide: platformBrowser.CollaborateSelectionAwarenessDelegate,
5622
+ useClass: TableSelectionAwarenessDelegate
5623
+ });
5086
5624
  }
5087
- const textbus = new core$1.Textbus({
5088
- zenCoding: true,
5089
- readonly: config.readonly,
5090
- imports: modules,
5091
- components: [
5625
+ const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
5626
+ [ParagraphComponent.componentName]: ParagraphView,
5627
+ [RootComponent.componentName]: RootView,
5628
+ [BlockquoteComponent.componentName]: BlockquoteView,
5629
+ [TodolistComponent.componentName]: TodolistView,
5630
+ [SourceCodeComponent.componentName]: SourceCodeView,
5631
+ [TableComponent.componentName]: TableComponentView,
5632
+ [HighlightBoxComponent.componentName]: HighlightBoxView,
5633
+ [ListComponent.componentName]: ListComponentView,
5634
+ [ImageComponent.componentName]: ImageView,
5635
+ [VideoComponent.componentName]: VideoView,
5636
+ [AtComponent.componentName]: AtComponentView,
5637
+ [KatexComponent.componentName]: KatexComponentView
5638
+ }, (host, root, injector) => {
5639
+ const appInjector = new core.ReflectiveInjector(injector, [{
5640
+ provide: OutputInjectionToken,
5641
+ useValue: true
5642
+ }, {
5643
+ provide: platformBrowser.DomAdapter,
5644
+ useFactory: () => {
5645
+ return vDomAdapter;
5646
+ }
5647
+ }]);
5648
+ const app = platformBrowser$1.createApp(root, {
5649
+ context: appInjector,
5650
+ nativeRenderer: new platformBrowser$1.HTMLRenderer()
5651
+ }).mount(host);
5652
+ return () => {
5653
+ app.destroy();
5654
+ };
5655
+ });
5656
+ super(Object.assign({ zenCoding: true, additionalAdapters: [vDomAdapter], imports: modules, components: [
5092
5657
  ImageComponent,
5093
5658
  ParagraphComponent,
5094
5659
  RootComponent,
@@ -5098,9 +5663,10 @@ function createXNote(host, config = {}) {
5098
5663
  TableComponent,
5099
5664
  HighlightBoxComponent,
5100
5665
  ListComponent,
5101
- VideoComponent
5102
- ],
5103
- formatters: [
5666
+ VideoComponent,
5667
+ AtComponent,
5668
+ KatexComponent
5669
+ ], formatters: [
5104
5670
  backgroundColorFormatter,
5105
5671
  boldFormatter,
5106
5672
  codeFormatter,
@@ -5111,18 +5677,14 @@ function createXNote(host, config = {}) {
5111
5677
  linkFormatter,
5112
5678
  strikeThroughFormatter,
5113
5679
  underlineFormatter
5114
- ],
5115
- attributes: [
5680
+ ], attributes: [
5116
5681
  headingAttr,
5117
5682
  textAlignAttr,
5118
5683
  textIndentAttr
5119
- ],
5120
- providers: [],
5121
- plugins: [
5684
+ ], plugins: [
5122
5685
  new LeftToolbarPlugin(),
5123
5686
  new ToolbarPlugin(),
5124
- ],
5125
- onAfterStartup(textbus) {
5687
+ ], onAfterStartup(textbus) {
5126
5688
  registerBoldShortcut(textbus);
5127
5689
  registerCodeShortcut(textbus);
5128
5690
  registerItalicShortcut(textbus);
@@ -5131,29 +5693,52 @@ function createXNote(host, config = {}) {
5131
5693
  registerHeadingShortcut(textbus);
5132
5694
  registerTextAlignShortcut(textbus);
5133
5695
  registerTextIndentShortcut(textbus);
5134
- }
5135
- });
5696
+ registerAtShortcut(textbus);
5697
+ registerListShortcut(textbus);
5698
+ registerBlockquoteShortcut(textbus);
5699
+ } }, editorConfig));
5700
+ this.editorConfig = editorConfig;
5701
+ this.translator = new platformBrowser$1.OutputTranslator();
5702
+ this.vDomAdapter = vDomAdapter;
5703
+ }
5704
+ mount(host) {
5705
+ this.host = host;
5136
5706
  let rootComp;
5707
+ const config = this.editorConfig;
5137
5708
  if (config.content) {
5138
- const parser = textbus.get(platformBrowser.Parser);
5709
+ const parser = this.get(platformBrowser.Parser);
5139
5710
  const doc = parser.parseDoc(config.content, rootComponentLoader);
5140
- rootComp = doc instanceof core$1.Component ? doc : new RootComponent(textbus, {
5141
- heading: new core$1.Slot([core$1.ContentType.Text]),
5142
- content: doc
5143
- });
5711
+ if (doc instanceof core$1.Component) {
5712
+ rootComp = doc;
5713
+ }
5714
+ else {
5715
+ const content = new core$1.Slot([
5716
+ core$1.ContentType.BlockComponent
5717
+ ]);
5718
+ if (doc instanceof core$1.Slot) {
5719
+ deltaToBlock(doc.toDelta(), this).forEach(i => {
5720
+ content.insert(i);
5721
+ });
5722
+ }
5723
+ rootComp = new RootComponent(this, {
5724
+ content
5725
+ });
5726
+ }
5144
5727
  }
5145
5728
  else {
5146
- rootComp = new RootComponent(textbus, {
5147
- heading: new core$1.Slot([core$1.ContentType.Text]),
5148
- content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
5729
+ rootComp = new RootComponent(this, {
5730
+ content: new core$1.Slot([core$1.ContentType.BlockComponent])
5149
5731
  });
5150
5732
  }
5151
- yield textbus.render(rootComp);
5152
- // console.log(rootComp)
5153
- return textbus;
5154
- });
5733
+ return this.render(rootComp);
5734
+ }
5735
+ getHTML() {
5736
+ return this.translator.transform(this.vDomAdapter.host);
5737
+ }
5155
5738
  }
5156
5739
 
5740
+ exports.AtComponent = AtComponent;
5741
+ exports.AtComponentView = AtComponentView;
5157
5742
  exports.AttrTool = AttrTool;
5158
5743
  exports.BlockTool = BlockTool;
5159
5744
  exports.BlockquoteComponent = BlockquoteComponent;
@@ -5167,6 +5752,7 @@ exports.Divider = Divider;
5167
5752
  exports.DragResize = DragResize;
5168
5753
  exports.Dropdown = Dropdown;
5169
5754
  exports.DropdownMenuPortal = DropdownMenuPortal;
5755
+ exports.Editor = Editor;
5170
5756
  exports.FontFamilyTool = FontFamilyTool;
5171
5757
  exports.FontSizeTool = FontSizeTool;
5172
5758
  exports.HighlightBoxComponent = HighlightBoxComponent;
@@ -5175,13 +5761,19 @@ exports.ImageComponent = ImageComponent;
5175
5761
  exports.ImageView = ImageView;
5176
5762
  exports.InsertTool = InsertTool;
5177
5763
  exports.ItalicTool = ItalicTool;
5764
+ exports.KatexComponent = KatexComponent;
5765
+ exports.KatexComponentView = KatexComponentView;
5766
+ exports.Keymap = Keymap;
5178
5767
  exports.LeftToolbar = LeftToolbar;
5179
5768
  exports.LeftToolbarPlugin = LeftToolbarPlugin;
5769
+ exports.LinkJump = LinkJump;
5180
5770
  exports.LinkTool = LinkTool;
5181
5771
  exports.ListComponent = ListComponent;
5182
5772
  exports.ListComponentView = ListComponentView;
5183
5773
  exports.Matcher = Matcher;
5774
+ exports.MenuHeading = MenuHeading;
5184
5775
  exports.MenuItem = MenuItem;
5776
+ exports.Organization = Organization;
5185
5777
  exports.OutputInjectionToken = OutputInjectionToken;
5186
5778
  exports.ParagraphComponent = ParagraphComponent;
5187
5779
  exports.ParagraphView = ParagraphView;
@@ -5201,6 +5793,7 @@ exports.ToolbarPlugin = ToolbarPlugin;
5201
5793
  exports.UnderlineTool = UnderlineTool;
5202
5794
  exports.VideoComponent = VideoComponent;
5203
5795
  exports.VideoView = VideoView;
5796
+ exports.atComponentLoader = atComponentLoader;
5204
5797
  exports.autoComplete = autoComplete;
5205
5798
  exports.backgroundColorFormatLoader = backgroundColorFormatLoader;
5206
5799
  exports.backgroundColorFormatter = backgroundColorFormatter;
@@ -5211,7 +5804,6 @@ exports.codeFormatLoader = codeFormatLoader;
5211
5804
  exports.codeFormatter = codeFormatter;
5212
5805
  exports.colorFormatLoader = colorFormatLoader;
5213
5806
  exports.colorFormatter = colorFormatter;
5214
- exports.createXNote = createXNote;
5215
5807
  exports.deltaToBlock = deltaToBlock;
5216
5808
  exports.fontFamilyFormatLoader = fontFamilyFormatLoader;
5217
5809
  exports.fontFamilyFormatter = fontFamilyFormatter;
@@ -5224,15 +5816,19 @@ exports.imageComponentLoader = imageComponentLoader;
5224
5816
  exports.isSupportFont = isSupportFont;
5225
5817
  exports.italicFormatLoader = italicFormatLoader;
5226
5818
  exports.italicFormatter = italicFormatter;
5819
+ exports.katexComponentLoader = katexComponentLoader;
5227
5820
  exports.languageList = languageList;
5228
5821
  exports.linkFormatLoader = linkFormatLoader;
5229
5822
  exports.linkFormatter = linkFormatter;
5230
5823
  exports.listComponentLoader = listComponentLoader;
5231
5824
  exports.paragraphComponentLoader = paragraphComponentLoader;
5825
+ exports.registerAtShortcut = registerAtShortcut;
5826
+ exports.registerBlockquoteShortcut = registerBlockquoteShortcut;
5232
5827
  exports.registerBoldShortcut = registerBoldShortcut;
5233
5828
  exports.registerCodeShortcut = registerCodeShortcut;
5234
5829
  exports.registerHeadingShortcut = registerHeadingShortcut;
5235
5830
  exports.registerItalicShortcut = registerItalicShortcut;
5831
+ exports.registerListShortcut = registerListShortcut;
5236
5832
  exports.registerStrikeThroughShortcut = registerStrikeThroughShortcut;
5237
5833
  exports.registerTextAlignShortcut = registerTextAlignShortcut;
5238
5834
  exports.registerTextIndentShortcut = registerTextIndentShortcut;
@@ -5247,6 +5843,8 @@ exports.textAlignAttr = textAlignAttr;
5247
5843
  exports.textAlignAttrLoader = textAlignAttrLoader;
5248
5844
  exports.textIndentAttr = textIndentAttr;
5249
5845
  exports.textIndentAttrLoader = textIndentAttrLoader;
5846
+ exports.toBlockquote = toBlockquote;
5847
+ exports.toList = toList;
5250
5848
  exports.todolistComponentLoader = todolistComponentLoader;
5251
5849
  exports.toggleBold = toggleBold;
5252
5850
  exports.toggleCode = toggleCode;