@textbus/xnote 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from '@viewfly/core/jsx-runtime';
2
2
  import { withScopedCSS } from '@viewfly/scoped-css';
3
3
  import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, getCurrentInstance, createRef, InjectionToken, withAnnotation, onUpdated, onMounted, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, Fragment as Fragment$1, Context, watch } from '@viewfly/core';
4
- import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, onParentSlotUpdated, Textbus, History, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, throttleTime, delay, tap, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
4
+ import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, onParentSlotUpdated, Textbus, History, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, delay, tap, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
5
5
  import { normalizeHex, hex2Hsl, hex2Rgb, hex2Hsv, hsl2Hex, hsl2Hsv, hsl2Rgb, rgb2Hsl, rgb2Hex, rgb2Hsv, hsv2Hex, hsv2Hsl, hsv2Rgb, any2Hsl, parseCss } from '@tanbo/color';
6
6
  import { VIEW_CONTAINER, isMac, DomAdapter, Input, BrowserModule, SelectionBridge, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, CollaborateCursor, Parser } from '@textbus/platform-browser';
7
7
  import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
@@ -12,7 +12,7 @@ import Katex from 'katex';
12
12
  import { ViewflyAdapter, ViewflyVDomAdapter } from '@textbus/adapter-viewfly';
13
13
  import { MessageBus, CollaborateModule } from '@textbus/collaborate';
14
14
 
15
- var scopedId$r = "vf-7d288d";
15
+ var scopedId$q = "vf-7d288d";
16
16
 
17
17
  /******************************************************************************
18
18
  Copyright (c) Microsoft Corporation.
@@ -145,7 +145,7 @@ function Button(props) {
145
145
  subscription.unsubscribe();
146
146
  });
147
147
  }
148
- return withScopedCSS(scopedId$r, () => {
148
+ return withScopedCSS(scopedId$q, () => {
149
149
  return (jsxs("button", Object.assign({ type: "button" }, props, { class: [
150
150
  'btn',
151
151
  {
@@ -157,7 +157,7 @@ function Button(props) {
157
157
  });
158
158
  }
159
159
 
160
- var scopedId$q = "vf-d552b9";
160
+ var scopedId$p = "vf-d552b9";
161
161
 
162
162
  class Picker {
163
163
  set hex(color) {
@@ -269,7 +269,6 @@ class Picker {
269
269
  this.hex = value || '#f00';
270
270
  }
271
271
  }
272
- const recentColors = createSignal([]);
273
272
  function ColorPicker(props) {
274
273
  const instance = getCurrentInstance();
275
274
  const picker = new Picker(() => {
@@ -286,6 +285,7 @@ function ColorPicker(props) {
286
285
  '#f63030', '#f88933', '#deb12a', '#038e23', '#1276cc', '#3f52ce', '#8838ed',
287
286
  '#c60000', '#d86912', '#b88811', '#086508', '#144c93', '#1b2eaa', '#6117bf',
288
287
  ];
288
+ const recentColors = createSignal(props.recentColors || []);
289
289
  function addRecentColor() {
290
290
  const color = picker.hex;
291
291
  if (!color) {
@@ -446,7 +446,7 @@ function ColorPicker(props) {
446
446
  props.onSelected(picker);
447
447
  addRecentColor();
448
448
  }
449
- return withScopedCSS(scopedId$q, () => {
449
+ return withScopedCSS(scopedId$p, () => {
450
450
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
451
451
  return (jsxs("div", { onMousedown: ev => {
452
452
  ev.stopPropagation();
@@ -465,7 +465,7 @@ function ColorPicker(props) {
465
465
  return (jsx("div", { "data-color": color, style: {
466
466
  background: color
467
467
  } }));
468
- }) }), jsx("div", { class: "xnote-color-picker-recent-text", children: "\u6700\u8FD1\u989C\u8272" }), jsx("div", { class: "xnote-color-picker-swatches", style: "height: 25px;", children: Array.from({ length: 7 }).map((_, index) => {
468
+ }) }), jsx("div", { class: "xnote-color-picker-recent-text", children: "\u5E38\u7528\u989C\u8272" }), jsx("div", { class: "xnote-color-picker-swatches", style: "height: 25px;", children: Array.from({ length: 7 }).map((_, index) => {
469
469
  const colors = recentColors();
470
470
  const color = colors[index] || '';
471
471
  return (jsx("div", { "data-color": color || 'unknown', style: {
@@ -497,10 +497,10 @@ function ColorPicker(props) {
497
497
  });
498
498
  }
499
499
 
500
- var scopedId$p = "vf-ac7e8d";
500
+ var scopedId$o = "vf-ac7e8d";
501
501
 
502
502
  function ComponentToolbar(props) {
503
- return withScopedCSS(scopedId$p, () => {
503
+ return withScopedCSS(scopedId$o, () => {
504
504
  return (jsx("div", { class: "component-toolbar", style: props.style, children: jsx("div", { class: [
505
505
  'toolbar',
506
506
  {
@@ -510,15 +510,15 @@ function ComponentToolbar(props) {
510
510
  });
511
511
  }
512
512
 
513
- var scopedId$o = "vf-ede279";
513
+ var scopedId$n = "vf-ede279";
514
514
 
515
515
  function Divider() {
516
- return withScopedCSS(scopedId$o, () => {
516
+ return withScopedCSS(scopedId$n, () => {
517
517
  return jsx("div", { class: "divider" });
518
518
  });
519
519
  }
520
520
 
521
- var scopedId$n = "vf-d91ad6";
521
+ var scopedId$m = "vf-d91ad6";
522
522
 
523
523
  function DragResize(props) {
524
524
  const isShow = createSignal(false);
@@ -627,16 +627,16 @@ function DragResize(props) {
627
627
  });
628
628
  }
629
629
  const sizeText = createSignal(`${component.state.width}*${component.state.height}`);
630
- return withScopedCSS(scopedId$n, () => {
630
+ return withScopedCSS(scopedId$m, () => {
631
631
  return (jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsx("div", { class: "container", ref: ref, children: props.children }), jsxs("div", { class: ['resize-tool', {
632
632
  active: isShow()
633
633
  }], children: [jsx("div", { class: "mask", ref: mask, children: sizeText() }), jsxs("div", { class: "btn-group", ref: btnGroup, onMousedown: drag, children: [jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" }), jsx("button", { type: "button" })] })] })] }));
634
634
  });
635
635
  }
636
636
 
637
- var scopedId$m = "vf-a99c5e";
637
+ var scopedId$l = "vf-cd482d";
638
638
 
639
- var scopedId$l = "vf-8a05e9";
639
+ var scopedId$k = "vf-8a05e9";
640
640
 
641
641
  const DropdownMenuContainer = new InjectionToken('DropdownMenuContainer');
642
642
  const DropdownMenuPortal = withAnnotation({
@@ -741,7 +741,7 @@ const DropdownMenuPortal = withAnnotation({
741
741
  function stopPropagation(ev) {
742
742
  ev.stopPropagation();
743
743
  }
744
- return createPortal(withScopedCSS(scopedId$l, () => {
744
+ return createPortal(withScopedCSS(scopedId$k, () => {
745
745
  return (jsx("div", { onMouseenter: onEnter, onMousedown: stopPropagation, onMouseleave: onLeave, ref: menuRef, style: {
746
746
  width: props.width
747
747
  }, class: "dropdown-menu", children: jsx("div", { class: "dropdown-menu-content", style: {
@@ -768,6 +768,7 @@ const Dropdown = withAnnotation({
768
768
  };
769
769
  const triggerRef = createRef();
770
770
  const dropdownRef = createRef();
771
+ const arrowRef = createRef();
771
772
  onMounted(() => {
772
773
  const sub = dropdownContextService.onOpenStateChange.subscribe(b => {
773
774
  var _a;
@@ -785,9 +786,10 @@ const Dropdown = withAnnotation({
785
786
  subscription.add(fromEvent(triggerRef.current, 'click').subscribe(toggle));
786
787
  return;
787
788
  }
789
+ const el = props.arrow ? arrowRef.current : dropdownRef.current;
788
790
  let leaveSub;
789
791
  const bindLeave = function () {
790
- leaveSub = fromEvent(dropdownRef.current, 'mouseleave').subscribe(() => {
792
+ leaveSub = fromEvent(el, 'mouseleave').subscribe(() => {
791
793
  if (props.disabled) {
792
794
  return;
793
795
  }
@@ -795,7 +797,7 @@ const Dropdown = withAnnotation({
795
797
  });
796
798
  };
797
799
  bindLeave();
798
- subscription.add(fromEvent(dropdownRef.current, 'mouseenter').subscribe(() => {
800
+ subscription.add(fromEvent(el, 'mouseenter').subscribe(() => {
799
801
  if (props.disabled) {
800
802
  return;
801
803
  }
@@ -818,8 +820,10 @@ const Dropdown = withAnnotation({
818
820
  dropdownContextService.hide(false);
819
821
  }
820
822
  },
821
- $render: withScopedCSS(scopedId$m, () => {
822
- return (jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() &&
823
+ $render: withScopedCSS(scopedId$l, () => {
824
+ return (jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsx("div", { class: ['dropdown-btn-inner', {
825
+ 'has-arrow': props.arrow
826
+ }], children: props.children }), props.arrow && jsx("div", { ref: arrowRef, class: "dropdown-btn-arrow", children: jsx(Button, { arrow: true }) })] }), isShow() &&
823
827
  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) ?
824
828
  props.menu.map(menu => {
825
829
  return (jsx("div", { class: "dropdown-menu-item", onClick: () => {
@@ -835,7 +839,7 @@ const Dropdown = withAnnotation({
835
839
  };
836
840
  });
837
841
 
838
- var scopedId$k = "vf-c32a7b";
842
+ var scopedId$j = "vf-c32a7b";
839
843
 
840
844
  function Keymap(props) {
841
845
  const arr = [];
@@ -869,20 +873,20 @@ function Keymap(props) {
869
873
  arr.push(jsx("span", { children: keymap.key }));
870
874
  }
871
875
  }
872
- return withScopedCSS(scopedId$k, () => {
876
+ return withScopedCSS(scopedId$j, () => {
873
877
  return (jsx("span", { class: "keymap", children: arr }));
874
878
  });
875
879
  }
876
880
 
877
- var scopedId$j = "vf-acaa5f";
881
+ var scopedId$i = "vf-acaa5f";
878
882
 
879
883
  function MenuHeading(props) {
880
- return withScopedCSS(scopedId$j, () => {
884
+ return withScopedCSS(scopedId$i, () => {
881
885
  return (jsx("div", { class: "menu-heading", children: props.children }));
882
886
  });
883
887
  }
884
888
 
885
- var scopedId$i = "vf-c3b9dc";
889
+ var scopedId$h = "vf-c3b9dc";
886
890
 
887
891
  function MenuItem(props) {
888
892
  const dropdownContextService = inject(DropdownContextService, null);
@@ -902,7 +906,7 @@ function MenuItem(props) {
902
906
  }
903
907
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
904
908
  }
905
- return withScopedCSS(scopedId$i, () => {
909
+ return withScopedCSS(scopedId$h, () => {
906
910
  return (jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxs("div", { class: "menu-item-content", children: [jsxs("div", { children: [props.icon && jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), jsx("div", { children: props.desc })] }), props.arrow ?
907
911
  jsx("div", { class: "arrow", children: jsx("span", { class: "xnote-icon-arrow-right" }) }) :
908
912
  jsx("div", { class: [
@@ -912,11 +916,11 @@ function MenuItem(props) {
912
916
  });
913
917
  }
914
918
 
915
- var scopedId$h = "vf-a23c47";
919
+ var scopedId$g = "vf-a23c47";
916
920
 
917
921
  function Popup(props) {
918
922
  const host = inject(VIEW_CONTAINER);
919
- return createPortal(withScopedCSS(scopedId$h, () => {
923
+ return createPortal(withScopedCSS(scopedId$g, () => {
920
924
  return (jsx("div", { class: "popup", style: {
921
925
  left: props.left + 'px',
922
926
  top: props.top + 'px'
@@ -924,15 +928,15 @@ function Popup(props) {
924
928
  }), host);
925
929
  }
926
930
 
927
- var scopedId$g = "vf-cd4d99";
931
+ var scopedId$f = "vf-cd4d99";
928
932
 
929
933
  function ToolbarItem(props) {
930
- return withScopedCSS(scopedId$g, () => {
934
+ return withScopedCSS(scopedId$f, () => {
931
935
  return (jsx("div", { class: "toolbar-item", children: props.children }));
932
936
  });
933
937
  }
934
938
 
935
- var scopedId$f = "vf-2a8a65";
939
+ var scopedId$e = "vf-2a8a65";
936
940
 
937
941
  let RefreshService = class RefreshService {
938
942
  constructor() {
@@ -2233,17 +2237,111 @@ function registerTextIndentShortcut(textbus) {
2233
2237
  });
2234
2238
  }
2235
2239
 
2240
+ class ImageComponent extends Component {
2241
+ static fromJSON(textbus, json) {
2242
+ return new ImageComponent(textbus, Object.assign({}, json));
2243
+ }
2244
+ getSlots() {
2245
+ return [];
2246
+ }
2247
+ }
2248
+ ImageComponent.type = ContentType.InlineComponent;
2249
+ ImageComponent.componentName = 'ImageComponent';
2250
+ function ImageView(props) {
2251
+ const { name, state } = props.component;
2252
+ const imageRef = createRef();
2253
+ const readonly = useReadonly();
2254
+ const output = useOutput();
2255
+ return () => {
2256
+ if (readonly() || output()) {
2257
+ return (jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsx("img", { alt: "", src: state.src, style: {
2258
+ width: state.width,
2259
+ height: state.height
2260
+ } }) }));
2261
+ }
2262
+ return (jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsx(DragResize, { source: imageRef, component: props.component, children: jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
2263
+ width: state.width,
2264
+ height: state.height
2265
+ } }) }) }));
2266
+ };
2267
+ }
2268
+ const imageComponentLoader = {
2269
+ match(element) {
2270
+ return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2271
+ },
2272
+ read(element, textbus) {
2273
+ const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2274
+ return new ImageComponent(textbus, {
2275
+ src: img.src,
2276
+ width: img.style.width || 'auto',
2277
+ height: img.style.height || 'auto'
2278
+ });
2279
+ }
2280
+ };
2281
+
2282
+ class VideoComponent extends Component {
2283
+ static fromJSON(textbus, json) {
2284
+ return new VideoComponent(textbus, Object.assign({}, json));
2285
+ }
2286
+ getSlots() {
2287
+ return [];
2288
+ }
2289
+ }
2290
+ VideoComponent.type = ContentType.InlineComponent;
2291
+ VideoComponent.componentName = 'VideoComponent';
2292
+ function VideoView(props) {
2293
+ const { name, state } = props.component;
2294
+ const videoRef = createRef();
2295
+ const readonly = useReadonly();
2296
+ const output = useOutput();
2297
+ return () => {
2298
+ if (readonly() || output()) {
2299
+ return (jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsx("video", { ref: videoRef, src: state.src, style: {
2300
+ width: state.width,
2301
+ height: state.height
2302
+ } }) }));
2303
+ }
2304
+ return (jsx("div", { ref: props.rootRef, class: "xnote-video", "data-component": name, children: jsx(DragResize, { source: videoRef, component: props.component, children: jsx("video", { ref: videoRef, src: state.src, style: {
2305
+ width: state.width,
2306
+ height: state.height
2307
+ } }) }) }));
2308
+ };
2309
+ }
2310
+ const videoComponentLoader = {
2311
+ match(element) {
2312
+ return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2313
+ },
2314
+ read(element, textbus) {
2315
+ const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2316
+ return new VideoComponent(textbus, {
2317
+ src: video.src,
2318
+ width: video.style.width || 'auto',
2319
+ height: video.style.height || 'auto'
2320
+ });
2321
+ }
2322
+ };
2323
+
2236
2324
  let ToolService = class ToolService {
2237
2325
  constructor(selection, controller) {
2238
2326
  this.selection = selection;
2239
2327
  this.controller = controller;
2240
2328
  const [state, updateState] = useProduce({
2241
2329
  inSourceCode: false,
2242
- readonly: controller.readonly
2330
+ readonly: controller.readonly,
2331
+ selectEmbed: false,
2243
2332
  });
2244
2333
  this.state = state;
2245
2334
  this.sub = merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2335
+ const { startSlot, endSlot, startOffset, endOffset } = selection;
2336
+ let is = false;
2337
+ if (startSlot && startSlot === endSlot && endOffset - startOffset === 1) {
2338
+ const component = startSlot.getContentAtIndex(startOffset);
2339
+ if (component instanceof VideoComponent || component instanceof ImageComponent) {
2340
+ is = true;
2341
+ }
2342
+ }
2246
2343
  updateState(draft => {
2344
+ draft.selectEmbed = is;
2247
2345
  draft.readonly = controller.readonly;
2248
2346
  draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
2249
2347
  });
@@ -2341,7 +2439,7 @@ function AttrTool(props) {
2341
2439
  }
2342
2440
  }
2343
2441
  const commonState = useCommonState();
2344
- return withScopedCSS(scopedId$f, () => {
2442
+ return withScopedCSS(scopedId$e, () => {
2345
2443
  const states = checkStates();
2346
2444
  const b = commonState().inSourceCode || commonState().readonly;
2347
2445
  return (jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
@@ -3632,7 +3730,7 @@ function BlockTool() {
3632
3730
  const checkStates = useActiveBlock();
3633
3731
  const transform = useBlockTransform();
3634
3732
  const commonState = useCommonState();
3635
- return withScopedCSS(scopedId$f, () => {
3733
+ return withScopedCSS(scopedId$e, () => {
3636
3734
  const states = checkStates();
3637
3735
  const types = [
3638
3736
  [states.paragraph, 'xnote-icon-pilcrow'],
@@ -4044,108 +4142,6 @@ function CodeTool() {
4044
4142
  };
4045
4143
  }
4046
4144
 
4047
- var scopedId$e = "vf-accb31";
4048
-
4049
- function ColorTool(props) {
4050
- const query = inject(Query);
4051
- const refreshService = inject(RefreshService);
4052
- const commander = inject(Commander);
4053
- const selection = inject(Selection);
4054
- const textColor = createSignal('');
4055
- const backgroundColor = createSignal('');
4056
- const [viewModel] = useProduce({
4057
- highlight: false,
4058
- });
4059
- function updateCheckState() {
4060
- if (!props.slot && !selection.isSelected) {
4061
- return;
4062
- }
4063
- const range = props.slot ? {
4064
- startSlot: props.slot,
4065
- endSlot: props.slot,
4066
- startOffset: 0,
4067
- endOffset: props.slot.length
4068
- } : {
4069
- startSlot: selection.startSlot,
4070
- startOffset: selection.startOffset,
4071
- endSlot: selection.endSlot,
4072
- endOffset: selection.endOffset
4073
- };
4074
- const textState = query.queryFormatByRange(colorFormatter, range);
4075
- const backgroundState = query.queryFormatByRange(backgroundColorFormatter, range);
4076
- textColor.set(textState.state === QueryStateType.Enabled ? textState.value : '');
4077
- backgroundColor.set(backgroundState.state === QueryStateType.Enabled ? backgroundState.value : '');
4078
- }
4079
- const sub = refreshService.onRefresh.subscribe(() => {
4080
- updateCheckState();
4081
- });
4082
- updateCheckState();
4083
- onUnmounted(() => {
4084
- sub.unsubscribe();
4085
- });
4086
- const textColors = [
4087
- '#000',
4088
- '#aaa',
4089
- '#ff2e2e',
4090
- '#ff8d45',
4091
- '#ffdf14',
4092
- '#5eec75',
4093
- '#5dfaff',
4094
- '#1296db',
4095
- '#617fff',
4096
- '#c459ff',
4097
- '#fff',
4098
- ];
4099
- const backgroundColors = [
4100
- '#aaa',
4101
- '#ef7373',
4102
- '#ec9c6a',
4103
- '#dccc64',
4104
- '#96e3a3',
4105
- '#a1e2e3',
4106
- '#90a0e5',
4107
- '#c596e0',
4108
- ];
4109
- const commonState = useCommonState();
4110
- return withScopedCSS(scopedId$e, () => {
4111
- const vm = viewModel();
4112
- return (jsx(Dropdown, { disabled: commonState().readonly || commonState().inSourceCode, style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxs("div", { children: [jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxs("div", { class: "text-colors", children: [jsx("div", { class: {
4113
- 'no-background': true,
4114
- active: textColor() === ''
4115
- }, onClick: () => {
4116
- var _a;
4117
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4118
- commander.unApplyFormat(colorFormatter);
4119
- } }), textColors.map(c => {
4120
- return jsx("div", { class: {
4121
- active: textColor() === c
4122
- }, onClick: () => {
4123
- var _a;
4124
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4125
- commander.applyFormat(colorFormatter, c);
4126
- }, style: { color: c }, children: "A" });
4127
- })] }), jsx("div", { class: "color-type", children: "\u80CC\u666F\u989C\u8272" }), jsxs("div", { class: "background-colors", children: [jsx("div", { class: {
4128
- active: backgroundColor() === '',
4129
- 'no-background': true
4130
- }, onClick: () => {
4131
- var _a;
4132
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4133
- commander.unApplyFormat(backgroundColorFormatter);
4134
- } }), backgroundColors.map(c => {
4135
- return jsx("div", { class: {
4136
- active: backgroundColor() === c
4137
- }, onClick: () => {
4138
- var _a;
4139
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4140
- commander.applyFormat(backgroundColorFormatter, c);
4141
- }, style: { backgroundColor: c }, children: "A" });
4142
- })] })] }), children: props.children || jsx(Button, { highlight: vm.highlight, arrow: true, disabled: commonState().readonly || commonState().inSourceCode, children: jsx("span", { class: "background", children: jsx("span", { style: {
4143
- backgroundColor: backgroundColor(),
4144
- color: textColor()
4145
- }, children: jsx("span", { class: "xnote-icon-color" }) }) }) }) }));
4146
- });
4147
- }
4148
-
4149
4145
  const isSupportFont = (function () {
4150
4146
  const fullbackFontName = 'Arial';
4151
4147
  const text = 'HeRe-is*SoMe%tEst +99.? !@ #~ &^teXtWw L$VEY$U0';
@@ -4312,90 +4308,6 @@ var scopedId$d = "vf-cf8e1c";
4312
4308
  class FileUploader {
4313
4309
  }
4314
4310
 
4315
- class ImageComponent extends Component {
4316
- static fromJSON(textbus, json) {
4317
- return new ImageComponent(textbus, Object.assign({}, json));
4318
- }
4319
- getSlots() {
4320
- return [];
4321
- }
4322
- }
4323
- ImageComponent.type = ContentType.InlineComponent;
4324
- ImageComponent.componentName = 'ImageComponent';
4325
- function ImageView(props) {
4326
- const { name, state } = props.component;
4327
- const imageRef = createRef();
4328
- const readonly = useReadonly();
4329
- const output = useOutput();
4330
- return () => {
4331
- if (readonly() || output()) {
4332
- return (jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsx("img", { alt: "", src: state.src, style: {
4333
- width: state.width,
4334
- height: state.height
4335
- } }) }));
4336
- }
4337
- return (jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsx(DragResize, { source: imageRef, component: props.component, children: jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
4338
- width: state.width,
4339
- height: state.height
4340
- } }) }) }));
4341
- };
4342
- }
4343
- const imageComponentLoader = {
4344
- match(element) {
4345
- return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
4346
- },
4347
- read(element, textbus) {
4348
- const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
4349
- return new ImageComponent(textbus, {
4350
- src: img.src,
4351
- width: img.style.width || 'auto',
4352
- height: img.style.height || 'auto'
4353
- });
4354
- }
4355
- };
4356
-
4357
- class VideoComponent extends Component {
4358
- static fromJSON(textbus, json) {
4359
- return new VideoComponent(textbus, Object.assign({}, json));
4360
- }
4361
- getSlots() {
4362
- return [];
4363
- }
4364
- }
4365
- VideoComponent.type = ContentType.InlineComponent;
4366
- VideoComponent.componentName = 'VideoComponent';
4367
- function VideoView(props) {
4368
- const { name, state } = props.component;
4369
- const videoRef = createRef();
4370
- const readonly = useReadonly();
4371
- const output = useOutput();
4372
- return () => {
4373
- if (readonly() || output()) {
4374
- return (jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsx("video", { ref: videoRef, src: state.src, style: {
4375
- width: state.width,
4376
- height: state.height
4377
- } }) }));
4378
- }
4379
- return (jsx("div", { ref: props.rootRef, class: "xnote-video", "data-component": name, children: jsx(DragResize, { source: videoRef, component: props.component, children: jsx("video", { ref: videoRef, src: state.src, style: {
4380
- width: state.width,
4381
- height: state.height
4382
- } }) }) }));
4383
- };
4384
- }
4385
- const videoComponentLoader = {
4386
- match(element) {
4387
- return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
4388
- },
4389
- read(element, textbus) {
4390
- const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
4391
- return new VideoComponent(textbus, {
4392
- src: video.src,
4393
- width: video.style.width || 'auto',
4394
- height: video.style.height || 'auto'
4395
- });
4396
- }
4397
- };
4398
-
4399
4311
  class KatexEditor extends Textbus {
4400
4312
  constructor() {
4401
4313
  const adapter = new ViewflyAdapter({
@@ -4939,6 +4851,100 @@ function SuperscriptTool() {
4939
4851
  };
4940
4852
  }
4941
4853
 
4854
+ function TextBackgroundColorTool(props) {
4855
+ const commander = inject(Commander);
4856
+ const color = createSignal('');
4857
+ function setColor(picker) {
4858
+ var _a;
4859
+ (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4860
+ const rgba = picker.rgba;
4861
+ if (rgba) {
4862
+ const c = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
4863
+ commander.applyFormat(backgroundColorFormatter, c);
4864
+ color.set(c);
4865
+ }
4866
+ else {
4867
+ commander.unApplyFormat(backgroundColorFormatter);
4868
+ color.set('');
4869
+ }
4870
+ }
4871
+ function setCurrentColor() {
4872
+ if (props.slot) {
4873
+ return;
4874
+ }
4875
+ const c = color();
4876
+ if (c) {
4877
+ commander.applyFormat(backgroundColorFormatter, c);
4878
+ }
4879
+ else {
4880
+ commander.unApplyFormat(backgroundColorFormatter);
4881
+ }
4882
+ }
4883
+ const commonState = useCommonState();
4884
+ const defaultColors = [
4885
+ '#ef7373',
4886
+ '#ec9c6a',
4887
+ '#dccc64',
4888
+ '#96e3a3',
4889
+ '#a1e2e3',
4890
+ '#90a0e5',
4891
+ '#c596e0',
4892
+ ];
4893
+ return () => {
4894
+ const disabled = commonState().readonly || commonState().inSourceCode || commonState().selectEmbed;
4895
+ return (jsx(Dropdown, { width: '177px', disabled: disabled, arrow: !props.children, abreast: props.abreast, style: props.style, menu: jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: props.children || jsx(Button, { onClick: setCurrentColor, disabled: disabled, children: jsx("span", { style: {
4896
+ color: disabled ? '' : color()
4897
+ }, class: "xnote-icon-background-color" }) }) }));
4898
+ };
4899
+ }
4900
+
4901
+ function TextColorTool(props) {
4902
+ const commander = inject(Commander);
4903
+ const color = createSignal('#ff0000');
4904
+ function setColor(picker) {
4905
+ var _a;
4906
+ (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4907
+ const rgba = picker.rgba;
4908
+ if (rgba) {
4909
+ const c = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
4910
+ commander.applyFormat(colorFormatter, c);
4911
+ color.set(c);
4912
+ }
4913
+ else {
4914
+ commander.unApplyFormat(colorFormatter);
4915
+ color.set('');
4916
+ }
4917
+ }
4918
+ function setCurrentColor() {
4919
+ if (props.slot) {
4920
+ return;
4921
+ }
4922
+ const c = color();
4923
+ if (c) {
4924
+ commander.applyFormat(colorFormatter, c);
4925
+ }
4926
+ else {
4927
+ commander.unApplyFormat(colorFormatter);
4928
+ }
4929
+ }
4930
+ const commonState = useCommonState();
4931
+ const defaultColors = [
4932
+ '#ff8d45',
4933
+ '#ffdf14',
4934
+ '#5eec75',
4935
+ '#5dfaff',
4936
+ '#1296db',
4937
+ '#617fff',
4938
+ '#c459ff',
4939
+ ];
4940
+ return () => {
4941
+ const disabled = commonState().readonly || commonState().inSourceCode || commonState().selectEmbed;
4942
+ return (jsx(Dropdown, { arrow: !props.children, width: '177px', style: props.style, disabled: disabled, abreast: props.abreast, menu: jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: props.children || jsx(Button, { onClick: setCurrentColor, disabled: disabled, children: jsx("span", { style: {
4943
+ color: disabled ? '' : color()
4944
+ }, class: "xnote-icon-color" }) }) }));
4945
+ };
4946
+ }
4947
+
4942
4948
  function UnderlineTool() {
4943
4949
  const query = inject(Query);
4944
4950
  const refreshService = inject(RefreshService);
@@ -4984,6 +4990,10 @@ function UndoTool() {
4984
4990
  }
4985
4991
 
4986
4992
  const cellAlignAttr = new Attribute('cellAlign', {
4993
+ onlySelf: true,
4994
+ checkHost(host) {
4995
+ return host.parent instanceof TableComponent;
4996
+ },
4987
4997
  render(node, formatValue) {
4988
4998
  node.styles.set('verticalAlign', formatValue);
4989
4999
  }
@@ -5093,8 +5103,9 @@ function CellAlignTool() {
5093
5103
  onUnmounted(() => {
5094
5104
  subscription.unsubscribe();
5095
5105
  });
5106
+ const commonState = useCommonState();
5096
5107
  return () => {
5097
- return (jsx(Dropdown, { onCheck: check, menu: [
5108
+ return (jsx(Dropdown, { disabled: commonState().readonly || commonState().inSourceCode, onCheck: check, menu: [
5098
5109
  {
5099
5110
  label: jsx(MenuItem, { checked: currentValue() === 'top', icon: jsx("span", { class: "xnote-icon-align-top" }), children: "\u9876\u90E8\u5BF9\u9F50" }),
5100
5111
  value: 'top'
@@ -5107,11 +5118,15 @@ function CellAlignTool() {
5107
5118
  label: jsx(MenuItem, { checked: currentValue() === 'bottom', icon: jsx("span", { class: "xnote-icon-align-bottom" }), children: "\u5E95\u90E8\u5BF9\u9F50" }),
5108
5119
  value: 'bottom'
5109
5120
  }
5110
- ], children: jsx(Button, { arrow: true, highlight: highlight(), children: jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
5121
+ ], children: jsx(Button, { arrow: true, disabled: commonState().readonly || commonState().inSourceCode, highlight: highlight(), children: jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
5111
5122
  };
5112
5123
  }
5113
5124
 
5114
5125
  const cellBackgroundAttr = new Attribute('cellBackground', {
5126
+ onlySelf: true,
5127
+ checkHost(host) {
5128
+ return host.parent instanceof TableComponent;
5129
+ },
5115
5130
  render(node, formatValue) {
5116
5131
  const rgba = parseCss(formatValue);
5117
5132
  if (rgba) {
@@ -5145,7 +5160,6 @@ function CellBackgroundTool() {
5145
5160
  const refreshService = inject(RefreshService);
5146
5161
  const selection = inject(Selection);
5147
5162
  const [viewModel, update] = useProduce({
5148
- highlight: false,
5149
5163
  disabled: false,
5150
5164
  });
5151
5165
  function setColor(picker) {
@@ -5158,7 +5172,9 @@ function CellBackgroundTool() {
5158
5172
  }).flat().forEach(slot => {
5159
5173
  const rgba = picker.rgba;
5160
5174
  if (rgba) {
5161
- slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
5175
+ slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`, s => {
5176
+ return slot === s;
5177
+ });
5162
5178
  }
5163
5179
  else {
5164
5180
  slot.removeAttribute(cellBackgroundAttr);
@@ -5191,9 +5207,20 @@ function CellBackgroundTool() {
5191
5207
  onUnmounted(() => {
5192
5208
  sub.unsubscribe();
5193
5209
  });
5210
+ const commonState = useCommonState();
5211
+ const defaultColors = [
5212
+ '#ef7373',
5213
+ '#ec9c6a',
5214
+ '#dccc64',
5215
+ '#96e3a3',
5216
+ '#a1e2e3',
5217
+ '#90a0e5',
5218
+ '#c596e0',
5219
+ ];
5194
5220
  return () => {
5195
5221
  const vm = viewModel();
5196
- return (jsx(Dropdown, { width: '177px', menu: jsx(ColorPicker, { onSelected: setColor }), trigger: 'hover', children: jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, children: jsx("span", { class: "xnote-icon-palette" }) }) }));
5222
+ const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
5223
+ return (jsx(Dropdown, { width: '177px', disabled: d, menu: jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: jsx(Button, { disabled: d, children: jsx("span", { class: "xnote-icon-palette" }) }) }));
5197
5224
  };
5198
5225
  }
5199
5226
 
@@ -5227,9 +5254,10 @@ function MergeCellsTool() {
5227
5254
  onUnmounted(() => {
5228
5255
  sub.unsubscribe();
5229
5256
  });
5257
+ const commonState = useCommonState();
5230
5258
  return () => {
5231
5259
  const vm = viewModel();
5232
- return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: merge, children: jsx("span", { class: "xnote-icon-merge-cells" }) });
5260
+ return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsx("span", { class: "xnote-icon-merge-cells" }) });
5233
5261
  };
5234
5262
  }
5235
5263
 
@@ -5298,9 +5326,10 @@ function SplitCellsTool() {
5298
5326
  onUnmounted(() => {
5299
5327
  sub.unsubscribe();
5300
5328
  });
5329
+ const commonState = useCommonState();
5301
5330
  return () => {
5302
5331
  const vm = viewModel();
5303
- return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: split, children: jsx("span", { class: "xnote-icon-split-cells" }) });
5332
+ return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsx("span", { class: "xnote-icon-split-cells" }) });
5304
5333
  };
5305
5334
  }
5306
5335
 
@@ -5404,13 +5433,7 @@ const LeftToolbar = withAnnotation({
5404
5433
  return;
5405
5434
  }
5406
5435
  refreshService.onRefresh.next();
5407
- }).add(selection.onChange.pipe(throttleTime(30)).subscribe(() => {
5408
- if (!selection.isCollapsed) {
5409
- updatePosition(draft => {
5410
- draft.display = false;
5411
- });
5412
- }
5413
- }));
5436
+ });
5414
5437
  onUnmounted(() => {
5415
5438
  subscription.unsubscribe();
5416
5439
  });
@@ -5510,7 +5533,7 @@ const LeftToolbar = withAnnotation({
5510
5533
  return (jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
5511
5534
  left: position.left + 'px',
5512
5535
  top: position.top + 'px',
5513
- display: position.display && selection.isCollapsed && editorService.canShowLeftToolbar ? 'block' : 'none'
5536
+ display: position.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5514
5537
  }, children: jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
5515
5538
  position: 'absolute',
5516
5539
  right: 0,
@@ -5518,7 +5541,7 @@ const LeftToolbar = withAnnotation({
5518
5541
  }, menu: isEmptyBlock() ?
5519
5542
  jsx(InsertMenu, { replace: !needInsert, slot: activeSlot() })
5520
5543
  :
5521
- jsxs(Fragment, { children: [jsxs("div", { class: "btn-group", children: [jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsx("span", { class: "xnote-icon-pilcrow" }) }), jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsx("span", { class: "xnote-icon-heading-h1" }) }), jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsx("span", { class: "xnote-icon-heading-h2" }) }), jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsx("span", { class: "xnote-icon-heading-h3" }) }), jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsx("span", { class: "xnote-icon-heading-h4" }) }), jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsx("span", { class: "xnote-icon-list-numbered" }) }), jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsx("span", { class: "xnote-icon-list" }) }), jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsx("span", { class: "xnote-icon-quotes-right" }) }), jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsx("span", { class: "xnote-icon-source-code" }) })] }), jsx(Divider, {}), jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsx(Divider, {}), jsx(MenuItem, { onClick: copy, icon: jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsx(MenuItem, { onClick: remove, icon: jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsx(MenuItem, { onClick: cut, icon: jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsx(Divider, {}), jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsx(InsertMenu, { hideTitle: true, slot: activeSlot() }), children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
5544
+ jsxs(Fragment, { children: [jsxs("div", { class: "btn-group", children: [jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsx("span", { class: "xnote-icon-pilcrow" }) }), jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsx("span", { class: "xnote-icon-heading-h1" }) }), jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsx("span", { class: "xnote-icon-heading-h2" }) }), jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsx("span", { class: "xnote-icon-heading-h3" }) }), jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsx("span", { class: "xnote-icon-heading-h4" }) }), jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsx("span", { class: "xnote-icon-list-numbered" }) }), jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsx("span", { class: "xnote-icon-list" }) }), jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsx("span", { class: "xnote-icon-quotes-right" }) }), jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsx("span", { class: "xnote-icon-source-code" }) })] }), jsx(Divider, {}), jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsx(TextColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-color" }), children: "\u6587\u672C\u989C\u8272" }) }), jsx(TextBackgroundColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-background-color" }), children: "\u6587\u672C\u80CC\u666F\u989C\u8272" }) }), jsx(Divider, {}), jsx(MenuItem, { onClick: copy, icon: jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsx(MenuItem, { onClick: remove, icon: jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsx(MenuItem, { onClick: cut, icon: jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsx(Divider, {}), jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsx(InsertMenu, { hideTitle: true, slot: activeSlot() }), children: jsx(MenuItem, { arrow: true, icon: jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
5522
5545
  jsx("span", { children: jsx("i", { class: "xnote-icon-plus" }) })
5523
5546
  :
5524
5547
  jsxs("span", { children: [activeNode, jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
@@ -5630,8 +5653,12 @@ const InlineToolbar = withAnnotation({
5630
5653
  const textbus = inject(Textbus);
5631
5654
  const editorService = inject(EditorService);
5632
5655
  const refreshService = inject(RefreshService);
5633
- const subscription = merge(textbus.onChange, selection.onChange).pipe(debounceTime(20)).subscribe(() => {
5656
+ const subscription = merge(textbus.onChange, selection.onChange).pipe(debounceTime(20), tap(() => {
5634
5657
  refreshService.onRefresh.next();
5658
+ }), delay(200)).subscribe(() => {
5659
+ if (viewPosition().isHide) {
5660
+ editorService.changeLeftToolbarVisible(true);
5661
+ }
5635
5662
  });
5636
5663
  onUnmounted(() => {
5637
5664
  subscription.unsubscribe();
@@ -5708,12 +5735,14 @@ const InlineToolbar = withAnnotation({
5708
5735
  const sub = textbus.onChange.pipe(debounceTime(100)).subscribe(() => {
5709
5736
  if (!viewPosition().isHide) {
5710
5737
  const top = getTop();
5711
- if (top !== null) {
5738
+ if (top !== null && !selection.isCollapsed) {
5712
5739
  updateViewPosition(draft => {
5713
5740
  draft.top = top;
5714
5741
  });
5742
+ return;
5715
5743
  }
5716
5744
  }
5745
+ editorService.changeLeftToolbarVisible(true);
5717
5746
  });
5718
5747
  onUnmounted(() => {
5719
5748
  sub.unsubscribe();
@@ -5737,6 +5766,10 @@ const InlineToolbar = withAnnotation({
5737
5766
  draft.opacity = 1;
5738
5767
  draft.top = top;
5739
5768
  });
5769
+ editorService.changeLeftToolbarVisible(false);
5770
+ }
5771
+ else {
5772
+ editorService.changeLeftToolbarVisible(true);
5740
5773
  }
5741
5774
  });
5742
5775
  }
@@ -5770,7 +5803,7 @@ const InlineToolbar = withAnnotation({
5770
5803
  opacity: p.opacity,
5771
5804
  display: editorService.hideInlineToolbar ? 'none' : '',
5772
5805
  transitionDuration: p.transitionDuration + 's'
5773
- }, children: [jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(ColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5806
+ }, children: [jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(TextColorTool, {}) }), jsx(ToolbarItem, { children: jsx(TextBackgroundColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5774
5807
  });
5775
5808
  });
5776
5809
 
@@ -5818,7 +5851,7 @@ const StaticToolbar = withAnnotation({
5818
5851
  subscription.unsubscribe();
5819
5852
  });
5820
5853
  return withScopedCSS(scopedId$7, () => {
5821
- return (jsxs("div", { class: ['toolbar', props.theme], children: [jsx(ToolbarItem, { children: jsx(UndoTool, {}) }), jsx(ToolbarItem, { children: jsx(RedoTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(InsertTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, {}) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(ColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5854
+ return (jsxs("div", { class: ['toolbar', props.theme], children: [jsx(ToolbarItem, { children: jsx(UndoTool, {}) }), jsx(ToolbarItem, { children: jsx(RedoTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(InsertTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, {}) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(TextColorTool, {}) }), jsx(ToolbarItem, { children: jsx(TextBackgroundColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5822
5855
  });
5823
5856
  });
5824
5857
 
@@ -5900,7 +5933,7 @@ const SuspensionToolbar = withAnnotation({
5900
5933
  top: s.top + 'px',
5901
5934
  opacity: s.opacity,
5902
5935
  pointerEvents: s.opacity === 0 ? 'none' : 'initial',
5903
- }, children: [jsx(ToolbarItem, { children: jsx(UndoTool, {}) }), jsx(ToolbarItem, { children: jsx(RedoTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(InsertTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, {}) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(ColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5936
+ }, children: [jsx(ToolbarItem, { children: jsx(UndoTool, {}) }), jsx(ToolbarItem, { children: jsx(RedoTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(InsertTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(LinkTool, {}) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(TextColorTool, {}) }), jsx(ToolbarItem, { children: jsx(TextBackgroundColorTool, {}) }), jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(SubscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(SuperscriptTool, {}) }), jsx(ToolbarItem, { children: jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === QueryStateType.Enabled && jsxs(Fragment$1, { children: [jsx(SplitLine, {}), jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table")] }));
5904
5937
  });
5905
5938
  });
5906
5939
 
@@ -7531,4 +7564,4 @@ class Editor extends Textbus {
7531
7564
  }
7532
7565
  }
7533
7566
 
7534
- export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CleanFormatsTool, CodeTool, ColorPicker, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuContainer, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InlineToolbar, InlineToolbarPlugin, InsertMenu, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Picker, Popup, RedoTool, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, SplitLine, StaticToolbar, StaticToolbarPlugin, StrikeThroughTool, SubscriptTool, SuperscriptTool, SuspensionToolbar, SuspensionToolbarPlugin, TableComponent, TableComponentView, TodolistComponent, TodolistView, ToolbarItem, UnderlineTool, UndoTool, VideoComponent, VideoView, XNoteMessageBus, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, cellBackgroundAttr, cellBackgroundAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, subscriptFormatLoader, subscriptFormatter, superscriptFormatLoader, superscriptFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };
7567
+ export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CleanFormatsTool, CodeTool, ColorPicker, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuContainer, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InlineToolbar, InlineToolbarPlugin, InsertMenu, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Picker, Popup, RedoTool, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, SplitLine, StaticToolbar, StaticToolbarPlugin, StrikeThroughTool, SubscriptTool, SuperscriptTool, SuspensionToolbar, SuspensionToolbarPlugin, TableComponent, TableComponentView, TextBackgroundColorTool, TextColorTool, TodolistComponent, TodolistView, ToolbarItem, UnderlineTool, UndoTool, VideoComponent, VideoView, XNoteMessageBus, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, cellBackgroundAttr, cellBackgroundAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, subscriptFormatLoader, subscriptFormatter, superscriptFormatLoader, superscriptFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };