@textbus/xnote 0.2.4 → 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.
package/bundles/index.js CHANGED
@@ -14,7 +14,7 @@ var Katex = require('katex');
14
14
  var adapterViewfly = require('@textbus/adapter-viewfly');
15
15
  var collaborate = require('@textbus/collaborate');
16
16
 
17
- var scopedId$r = "vf-7d288d";
17
+ var scopedId$q = "vf-7d288d";
18
18
 
19
19
  /******************************************************************************
20
20
  Copyright (c) Microsoft Corporation.
@@ -147,7 +147,7 @@ function Button(props) {
147
147
  subscription.unsubscribe();
148
148
  });
149
149
  }
150
- return scopedCss.withScopedCSS(scopedId$r, () => {
150
+ return scopedCss.withScopedCSS(scopedId$q, () => {
151
151
  return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
152
152
  'btn',
153
153
  {
@@ -159,7 +159,7 @@ function Button(props) {
159
159
  });
160
160
  }
161
161
 
162
- var scopedId$q = "vf-d552b9";
162
+ var scopedId$p = "vf-d552b9";
163
163
 
164
164
  class Picker {
165
165
  set hex(color$1) {
@@ -271,7 +271,6 @@ class Picker {
271
271
  this.hex = value || '#f00';
272
272
  }
273
273
  }
274
- const recentColors = core.createSignal([]);
275
274
  function ColorPicker(props) {
276
275
  const instance = core.getCurrentInstance();
277
276
  const picker = new Picker(() => {
@@ -288,6 +287,7 @@ function ColorPicker(props) {
288
287
  '#f63030', '#f88933', '#deb12a', '#038e23', '#1276cc', '#3f52ce', '#8838ed',
289
288
  '#c60000', '#d86912', '#b88811', '#086508', '#144c93', '#1b2eaa', '#6117bf',
290
289
  ];
290
+ const recentColors = core.createSignal(props.recentColors || []);
291
291
  function addRecentColor() {
292
292
  const color = picker.hex;
293
293
  if (!color) {
@@ -448,7 +448,7 @@ function ColorPicker(props) {
448
448
  props.onSelected(picker);
449
449
  addRecentColor();
450
450
  }
451
- return scopedCss.withScopedCSS(scopedId$q, () => {
451
+ return scopedCss.withScopedCSS(scopedId$p, () => {
452
452
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
453
453
  return (jsxRuntime.jsxs("div", { onMousedown: ev => {
454
454
  ev.stopPropagation();
@@ -467,7 +467,7 @@ function ColorPicker(props) {
467
467
  return (jsxRuntime.jsx("div", { "data-color": color, style: {
468
468
  background: color
469
469
  } }));
470
- }) }), jsxRuntime.jsx("div", { class: "xnote-color-picker-recent-text", children: "\u6700\u8FD1\u989C\u8272" }), jsxRuntime.jsx("div", { class: "xnote-color-picker-swatches", style: "height: 25px;", children: Array.from({ length: 7 }).map((_, index) => {
470
+ }) }), jsxRuntime.jsx("div", { class: "xnote-color-picker-recent-text", children: "\u5E38\u7528\u989C\u8272" }), jsxRuntime.jsx("div", { class: "xnote-color-picker-swatches", style: "height: 25px;", children: Array.from({ length: 7 }).map((_, index) => {
471
471
  const colors = recentColors();
472
472
  const color = colors[index] || '';
473
473
  return (jsxRuntime.jsx("div", { "data-color": color || 'unknown', style: {
@@ -499,10 +499,10 @@ function ColorPicker(props) {
499
499
  });
500
500
  }
501
501
 
502
- var scopedId$p = "vf-ac7e8d";
502
+ var scopedId$o = "vf-ac7e8d";
503
503
 
504
504
  function ComponentToolbar(props) {
505
- return scopedCss.withScopedCSS(scopedId$p, () => {
505
+ return scopedCss.withScopedCSS(scopedId$o, () => {
506
506
  return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
507
507
  'toolbar',
508
508
  {
@@ -512,15 +512,15 @@ function ComponentToolbar(props) {
512
512
  });
513
513
  }
514
514
 
515
- var scopedId$o = "vf-ede279";
515
+ var scopedId$n = "vf-ede279";
516
516
 
517
517
  function Divider() {
518
- return scopedCss.withScopedCSS(scopedId$o, () => {
518
+ return scopedCss.withScopedCSS(scopedId$n, () => {
519
519
  return jsxRuntime.jsx("div", { class: "divider" });
520
520
  });
521
521
  }
522
522
 
523
- var scopedId$n = "vf-d91ad6";
523
+ var scopedId$m = "vf-d91ad6";
524
524
 
525
525
  function DragResize(props) {
526
526
  const isShow = core.createSignal(false);
@@ -629,16 +629,16 @@ function DragResize(props) {
629
629
  });
630
630
  }
631
631
  const sizeText = core.createSignal(`${component.state.width}*${component.state.height}`);
632
- return scopedCss.withScopedCSS(scopedId$n, () => {
632
+ return scopedCss.withScopedCSS(scopedId$m, () => {
633
633
  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', {
634
634
  active: isShow()
635
635
  }], children: [jsxRuntime.jsx("div", { class: "mask", ref: mask, children: sizeText() }), 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" })] })] })] }));
636
636
  });
637
637
  }
638
638
 
639
- var scopedId$m = "vf-a99c5e";
639
+ var scopedId$l = "vf-cd482d";
640
640
 
641
- var scopedId$l = "vf-8a05e9";
641
+ var scopedId$k = "vf-8a05e9";
642
642
 
643
643
  const DropdownMenuContainer = new core.InjectionToken('DropdownMenuContainer');
644
644
  const DropdownMenuPortal = core.withAnnotation({
@@ -743,7 +743,7 @@ const DropdownMenuPortal = core.withAnnotation({
743
743
  function stopPropagation(ev) {
744
744
  ev.stopPropagation();
745
745
  }
746
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$l, () => {
746
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$k, () => {
747
747
  return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMousedown: stopPropagation, onMouseleave: onLeave, ref: menuRef, style: {
748
748
  width: props.width
749
749
  }, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
@@ -770,6 +770,7 @@ const Dropdown = core.withAnnotation({
770
770
  };
771
771
  const triggerRef = core.createRef();
772
772
  const dropdownRef = core.createRef();
773
+ const arrowRef = core.createRef();
773
774
  core.onMounted(() => {
774
775
  const sub = dropdownContextService.onOpenStateChange.subscribe(b => {
775
776
  var _a;
@@ -787,9 +788,10 @@ const Dropdown = core.withAnnotation({
787
788
  subscription.add(core$1.fromEvent(triggerRef.current, 'click').subscribe(toggle));
788
789
  return;
789
790
  }
791
+ const el = props.arrow ? arrowRef.current : dropdownRef.current;
790
792
  let leaveSub;
791
793
  const bindLeave = function () {
792
- leaveSub = core$1.fromEvent(dropdownRef.current, 'mouseleave').subscribe(() => {
794
+ leaveSub = core$1.fromEvent(el, 'mouseleave').subscribe(() => {
793
795
  if (props.disabled) {
794
796
  return;
795
797
  }
@@ -797,7 +799,7 @@ const Dropdown = core.withAnnotation({
797
799
  });
798
800
  };
799
801
  bindLeave();
800
- subscription.add(core$1.fromEvent(dropdownRef.current, 'mouseenter').subscribe(() => {
802
+ subscription.add(core$1.fromEvent(el, 'mouseenter').subscribe(() => {
801
803
  if (props.disabled) {
802
804
  return;
803
805
  }
@@ -820,8 +822,10 @@ const Dropdown = core.withAnnotation({
820
822
  dropdownContextService.hide(false);
821
823
  }
822
824
  },
823
- $render: scopedCss.withScopedCSS(scopedId$m, () => {
824
- 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() &&
825
+ $render: scopedCss.withScopedCSS(scopedId$l, () => {
826
+ 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', {
827
+ 'has-arrow': props.arrow
828
+ }], children: props.children }), props.arrow && jsxRuntime.jsx("div", { ref: arrowRef, class: "dropdown-btn-arrow", children: jsxRuntime.jsx(Button, { arrow: true }) })] }), isShow() &&
825
829
  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) ?
826
830
  props.menu.map(menu => {
827
831
  return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
@@ -837,7 +841,7 @@ const Dropdown = core.withAnnotation({
837
841
  };
838
842
  });
839
843
 
840
- var scopedId$k = "vf-c32a7b";
844
+ var scopedId$j = "vf-c32a7b";
841
845
 
842
846
  function Keymap(props) {
843
847
  const arr = [];
@@ -871,20 +875,20 @@ function Keymap(props) {
871
875
  arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
872
876
  }
873
877
  }
874
- return scopedCss.withScopedCSS(scopedId$k, () => {
878
+ return scopedCss.withScopedCSS(scopedId$j, () => {
875
879
  return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
876
880
  });
877
881
  }
878
882
 
879
- var scopedId$j = "vf-acaa5f";
883
+ var scopedId$i = "vf-acaa5f";
880
884
 
881
885
  function MenuHeading(props) {
882
- return scopedCss.withScopedCSS(scopedId$j, () => {
886
+ return scopedCss.withScopedCSS(scopedId$i, () => {
883
887
  return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
884
888
  });
885
889
  }
886
890
 
887
- var scopedId$i = "vf-c3b9dc";
891
+ var scopedId$h = "vf-c3b9dc";
888
892
 
889
893
  function MenuItem(props) {
890
894
  const dropdownContextService = core.inject(exports.DropdownContextService, null);
@@ -904,7 +908,7 @@ function MenuItem(props) {
904
908
  }
905
909
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
906
910
  }
907
- return scopedCss.withScopedCSS(scopedId$i, () => {
911
+ return scopedCss.withScopedCSS(scopedId$h, () => {
908
912
  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 ?
909
913
  jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
910
914
  jsxRuntime.jsx("div", { class: [
@@ -914,11 +918,11 @@ function MenuItem(props) {
914
918
  });
915
919
  }
916
920
 
917
- var scopedId$h = "vf-a23c47";
921
+ var scopedId$g = "vf-a23c47";
918
922
 
919
923
  function Popup(props) {
920
924
  const host = core.inject(platformBrowser.VIEW_CONTAINER);
921
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$h, () => {
925
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$g, () => {
922
926
  return (jsxRuntime.jsx("div", { class: "popup", style: {
923
927
  left: props.left + 'px',
924
928
  top: props.top + 'px'
@@ -926,15 +930,15 @@ function Popup(props) {
926
930
  }), host);
927
931
  }
928
932
 
929
- var scopedId$g = "vf-cd4d99";
933
+ var scopedId$f = "vf-cd4d99";
930
934
 
931
935
  function ToolbarItem(props) {
932
- return scopedCss.withScopedCSS(scopedId$g, () => {
936
+ return scopedCss.withScopedCSS(scopedId$f, () => {
933
937
  return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
934
938
  });
935
939
  }
936
940
 
937
- var scopedId$f = "vf-2a8a65";
941
+ var scopedId$e = "vf-2a8a65";
938
942
 
939
943
  exports.RefreshService = class RefreshService {
940
944
  constructor() {
@@ -2235,17 +2239,111 @@ function registerTextIndentShortcut(textbus) {
2235
2239
  });
2236
2240
  }
2237
2241
 
2242
+ class ImageComponent extends core$1.Component {
2243
+ static fromJSON(textbus, json) {
2244
+ return new ImageComponent(textbus, Object.assign({}, json));
2245
+ }
2246
+ getSlots() {
2247
+ return [];
2248
+ }
2249
+ }
2250
+ ImageComponent.type = core$1.ContentType.InlineComponent;
2251
+ ImageComponent.componentName = 'ImageComponent';
2252
+ function ImageView(props) {
2253
+ const { name, state } = props.component;
2254
+ const imageRef = core.createRef();
2255
+ const readonly = useReadonly();
2256
+ const output = useOutput();
2257
+ return () => {
2258
+ if (readonly() || output()) {
2259
+ return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
2260
+ width: state.width,
2261
+ height: state.height
2262
+ } }) }));
2263
+ }
2264
+ 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: {
2265
+ width: state.width,
2266
+ height: state.height
2267
+ } }) }) }));
2268
+ };
2269
+ }
2270
+ const imageComponentLoader = {
2271
+ match(element) {
2272
+ return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2273
+ },
2274
+ read(element, textbus) {
2275
+ const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2276
+ return new ImageComponent(textbus, {
2277
+ src: img.src,
2278
+ width: img.style.width || 'auto',
2279
+ height: img.style.height || 'auto'
2280
+ });
2281
+ }
2282
+ };
2283
+
2284
+ class VideoComponent extends core$1.Component {
2285
+ static fromJSON(textbus, json) {
2286
+ return new VideoComponent(textbus, Object.assign({}, json));
2287
+ }
2288
+ getSlots() {
2289
+ return [];
2290
+ }
2291
+ }
2292
+ VideoComponent.type = core$1.ContentType.InlineComponent;
2293
+ VideoComponent.componentName = 'VideoComponent';
2294
+ function VideoView(props) {
2295
+ const { name, state } = props.component;
2296
+ const videoRef = core.createRef();
2297
+ const readonly = useReadonly();
2298
+ const output = useOutput();
2299
+ return () => {
2300
+ if (readonly() || output()) {
2301
+ return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
2302
+ width: state.width,
2303
+ height: state.height
2304
+ } }) }));
2305
+ }
2306
+ 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: {
2307
+ width: state.width,
2308
+ height: state.height
2309
+ } }) }) }));
2310
+ };
2311
+ }
2312
+ const videoComponentLoader = {
2313
+ match(element) {
2314
+ return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2315
+ },
2316
+ read(element, textbus) {
2317
+ const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2318
+ return new VideoComponent(textbus, {
2319
+ src: video.src,
2320
+ width: video.style.width || 'auto',
2321
+ height: video.style.height || 'auto'
2322
+ });
2323
+ }
2324
+ };
2325
+
2238
2326
  let ToolService = class ToolService {
2239
2327
  constructor(selection, controller) {
2240
2328
  this.selection = selection;
2241
2329
  this.controller = controller;
2242
2330
  const [state, updateState] = hooks.useProduce({
2243
2331
  inSourceCode: false,
2244
- readonly: controller.readonly
2332
+ readonly: controller.readonly,
2333
+ selectEmbed: false,
2245
2334
  });
2246
2335
  this.state = state;
2247
2336
  this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2337
+ const { startSlot, endSlot, startOffset, endOffset } = selection;
2338
+ let is = false;
2339
+ if (startSlot && startSlot === endSlot && endOffset - startOffset === 1) {
2340
+ const component = startSlot.getContentAtIndex(startOffset);
2341
+ if (component instanceof VideoComponent || component instanceof ImageComponent) {
2342
+ is = true;
2343
+ }
2344
+ }
2248
2345
  updateState(draft => {
2346
+ draft.selectEmbed = is;
2249
2347
  draft.readonly = controller.readonly;
2250
2348
  draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
2251
2349
  });
@@ -2343,7 +2441,7 @@ function AttrTool(props) {
2343
2441
  }
2344
2442
  }
2345
2443
  const commonState = useCommonState();
2346
- return scopedCss.withScopedCSS(scopedId$f, () => {
2444
+ return scopedCss.withScopedCSS(scopedId$e, () => {
2347
2445
  const states = checkStates();
2348
2446
  const b = commonState().inSourceCode || commonState().readonly;
2349
2447
  return (jsxRuntime.jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
@@ -3634,7 +3732,7 @@ function BlockTool() {
3634
3732
  const checkStates = useActiveBlock();
3635
3733
  const transform = useBlockTransform();
3636
3734
  const commonState = useCommonState();
3637
- return scopedCss.withScopedCSS(scopedId$f, () => {
3735
+ return scopedCss.withScopedCSS(scopedId$e, () => {
3638
3736
  const states = checkStates();
3639
3737
  const types = [
3640
3738
  [states.paragraph, 'xnote-icon-pilcrow'],
@@ -4046,108 +4144,6 @@ function CodeTool() {
4046
4144
  };
4047
4145
  }
4048
4146
 
4049
- var scopedId$e = "vf-accb31";
4050
-
4051
- function ColorTool(props) {
4052
- const query = core.inject(core$1.Query);
4053
- const refreshService = core.inject(exports.RefreshService);
4054
- const commander = core.inject(core$1.Commander);
4055
- const selection = core.inject(core$1.Selection);
4056
- const textColor = core.createSignal('');
4057
- const backgroundColor = core.createSignal('');
4058
- const [viewModel] = hooks.useProduce({
4059
- highlight: false,
4060
- });
4061
- function updateCheckState() {
4062
- if (!props.slot && !selection.isSelected) {
4063
- return;
4064
- }
4065
- const range = props.slot ? {
4066
- startSlot: props.slot,
4067
- endSlot: props.slot,
4068
- startOffset: 0,
4069
- endOffset: props.slot.length
4070
- } : {
4071
- startSlot: selection.startSlot,
4072
- startOffset: selection.startOffset,
4073
- endSlot: selection.endSlot,
4074
- endOffset: selection.endOffset
4075
- };
4076
- const textState = query.queryFormatByRange(colorFormatter, range);
4077
- const backgroundState = query.queryFormatByRange(backgroundColorFormatter, range);
4078
- textColor.set(textState.state === core$1.QueryStateType.Enabled ? textState.value : '');
4079
- backgroundColor.set(backgroundState.state === core$1.QueryStateType.Enabled ? backgroundState.value : '');
4080
- }
4081
- const sub = refreshService.onRefresh.subscribe(() => {
4082
- updateCheckState();
4083
- });
4084
- updateCheckState();
4085
- core.onUnmounted(() => {
4086
- sub.unsubscribe();
4087
- });
4088
- const textColors = [
4089
- '#000',
4090
- '#aaa',
4091
- '#ff2e2e',
4092
- '#ff8d45',
4093
- '#ffdf14',
4094
- '#5eec75',
4095
- '#5dfaff',
4096
- '#1296db',
4097
- '#617fff',
4098
- '#c459ff',
4099
- '#fff',
4100
- ];
4101
- const backgroundColors = [
4102
- '#aaa',
4103
- '#ef7373',
4104
- '#ec9c6a',
4105
- '#dccc64',
4106
- '#96e3a3',
4107
- '#a1e2e3',
4108
- '#90a0e5',
4109
- '#c596e0',
4110
- ];
4111
- const commonState = useCommonState();
4112
- return scopedCss.withScopedCSS(scopedId$e, () => {
4113
- const vm = viewModel();
4114
- return (jsxRuntime.jsx(Dropdown, { disabled: commonState().readonly || commonState().inSourceCode, 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: {
4115
- 'no-background': true,
4116
- active: textColor() === ''
4117
- }, onClick: () => {
4118
- var _a;
4119
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4120
- commander.unApplyFormat(colorFormatter);
4121
- } }), textColors.map(c => {
4122
- return jsxRuntime.jsx("div", { class: {
4123
- active: textColor() === c
4124
- }, onClick: () => {
4125
- var _a;
4126
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4127
- commander.applyFormat(colorFormatter, c);
4128
- }, style: { color: c }, children: "A" });
4129
- })] }), jsxRuntime.jsx("div", { class: "color-type", children: "\u80CC\u666F\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "background-colors", children: [jsxRuntime.jsx("div", { class: {
4130
- active: backgroundColor() === '',
4131
- 'no-background': true
4132
- }, onClick: () => {
4133
- var _a;
4134
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4135
- commander.unApplyFormat(backgroundColorFormatter);
4136
- } }), backgroundColors.map(c => {
4137
- return jsxRuntime.jsx("div", { class: {
4138
- active: backgroundColor() === c
4139
- }, onClick: () => {
4140
- var _a;
4141
- (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4142
- commander.applyFormat(backgroundColorFormatter, c);
4143
- }, style: { backgroundColor: c }, children: "A" });
4144
- })] })] }), children: props.children || jsxRuntime.jsx(Button, { highlight: vm.highlight, arrow: true, disabled: commonState().readonly || commonState().inSourceCode, children: jsxRuntime.jsx("span", { class: "background", children: jsxRuntime.jsx("span", { style: {
4145
- backgroundColor: backgroundColor(),
4146
- color: textColor()
4147
- }, children: jsxRuntime.jsx("span", { class: "xnote-icon-color" }) }) }) }) }));
4148
- });
4149
- }
4150
-
4151
4147
  const isSupportFont = (function () {
4152
4148
  const fullbackFontName = 'Arial';
4153
4149
  const text = 'HeRe-is*SoMe%tEst +99.? !@ #~ &^teXtWw L$VEY$U0';
@@ -4314,90 +4310,6 @@ var scopedId$d = "vf-cf8e1c";
4314
4310
  class FileUploader {
4315
4311
  }
4316
4312
 
4317
- class ImageComponent extends core$1.Component {
4318
- static fromJSON(textbus, json) {
4319
- return new ImageComponent(textbus, Object.assign({}, json));
4320
- }
4321
- getSlots() {
4322
- return [];
4323
- }
4324
- }
4325
- ImageComponent.type = core$1.ContentType.InlineComponent;
4326
- ImageComponent.componentName = 'ImageComponent';
4327
- function ImageView(props) {
4328
- const { name, state } = props.component;
4329
- const imageRef = core.createRef();
4330
- const readonly = useReadonly();
4331
- const output = useOutput();
4332
- return () => {
4333
- if (readonly() || output()) {
4334
- return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
4335
- width: state.width,
4336
- height: state.height
4337
- } }) }));
4338
- }
4339
- 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: {
4340
- width: state.width,
4341
- height: state.height
4342
- } }) }) }));
4343
- };
4344
- }
4345
- const imageComponentLoader = {
4346
- match(element) {
4347
- return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
4348
- },
4349
- read(element, textbus) {
4350
- const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
4351
- return new ImageComponent(textbus, {
4352
- src: img.src,
4353
- width: img.style.width || 'auto',
4354
- height: img.style.height || 'auto'
4355
- });
4356
- }
4357
- };
4358
-
4359
- class VideoComponent extends core$1.Component {
4360
- static fromJSON(textbus, json) {
4361
- return new VideoComponent(textbus, Object.assign({}, json));
4362
- }
4363
- getSlots() {
4364
- return [];
4365
- }
4366
- }
4367
- VideoComponent.type = core$1.ContentType.InlineComponent;
4368
- VideoComponent.componentName = 'VideoComponent';
4369
- function VideoView(props) {
4370
- const { name, state } = props.component;
4371
- const videoRef = core.createRef();
4372
- const readonly = useReadonly();
4373
- const output = useOutput();
4374
- return () => {
4375
- if (readonly() || output()) {
4376
- return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
4377
- width: state.width,
4378
- height: state.height
4379
- } }) }));
4380
- }
4381
- 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: {
4382
- width: state.width,
4383
- height: state.height
4384
- } }) }) }));
4385
- };
4386
- }
4387
- const videoComponentLoader = {
4388
- match(element) {
4389
- return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
4390
- },
4391
- read(element, textbus) {
4392
- const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
4393
- return new VideoComponent(textbus, {
4394
- src: video.src,
4395
- width: video.style.width || 'auto',
4396
- height: video.style.height || 'auto'
4397
- });
4398
- }
4399
- };
4400
-
4401
4313
  class KatexEditor extends core$1.Textbus {
4402
4314
  constructor() {
4403
4315
  const adapter = new adapterViewfly.ViewflyAdapter({
@@ -4941,6 +4853,100 @@ function SuperscriptTool() {
4941
4853
  };
4942
4854
  }
4943
4855
 
4856
+ function TextBackgroundColorTool(props) {
4857
+ const commander = core.inject(core$1.Commander);
4858
+ const color = core.createSignal('');
4859
+ function setColor(picker) {
4860
+ var _a;
4861
+ (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4862
+ const rgba = picker.rgba;
4863
+ if (rgba) {
4864
+ const c = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
4865
+ commander.applyFormat(backgroundColorFormatter, c);
4866
+ color.set(c);
4867
+ }
4868
+ else {
4869
+ commander.unApplyFormat(backgroundColorFormatter);
4870
+ color.set('');
4871
+ }
4872
+ }
4873
+ function setCurrentColor() {
4874
+ if (props.slot) {
4875
+ return;
4876
+ }
4877
+ const c = color();
4878
+ if (c) {
4879
+ commander.applyFormat(backgroundColorFormatter, c);
4880
+ }
4881
+ else {
4882
+ commander.unApplyFormat(backgroundColorFormatter);
4883
+ }
4884
+ }
4885
+ const commonState = useCommonState();
4886
+ const defaultColors = [
4887
+ '#ef7373',
4888
+ '#ec9c6a',
4889
+ '#dccc64',
4890
+ '#96e3a3',
4891
+ '#a1e2e3',
4892
+ '#90a0e5',
4893
+ '#c596e0',
4894
+ ];
4895
+ return () => {
4896
+ const disabled = commonState().readonly || commonState().inSourceCode || commonState().selectEmbed;
4897
+ return (jsxRuntime.jsx(Dropdown, { width: '177px', disabled: disabled, arrow: !props.children, abreast: props.abreast, style: props.style, menu: jsxRuntime.jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: props.children || jsxRuntime.jsx(Button, { onClick: setCurrentColor, disabled: disabled, children: jsxRuntime.jsx("span", { style: {
4898
+ color: disabled ? '' : color()
4899
+ }, class: "xnote-icon-background-color" }) }) }));
4900
+ };
4901
+ }
4902
+
4903
+ function TextColorTool(props) {
4904
+ const commander = core.inject(core$1.Commander);
4905
+ const color = core.createSignal('#ff0000');
4906
+ function setColor(picker) {
4907
+ var _a;
4908
+ (_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
4909
+ const rgba = picker.rgba;
4910
+ if (rgba) {
4911
+ const c = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
4912
+ commander.applyFormat(colorFormatter, c);
4913
+ color.set(c);
4914
+ }
4915
+ else {
4916
+ commander.unApplyFormat(colorFormatter);
4917
+ color.set('');
4918
+ }
4919
+ }
4920
+ function setCurrentColor() {
4921
+ if (props.slot) {
4922
+ return;
4923
+ }
4924
+ const c = color();
4925
+ if (c) {
4926
+ commander.applyFormat(colorFormatter, c);
4927
+ }
4928
+ else {
4929
+ commander.unApplyFormat(colorFormatter);
4930
+ }
4931
+ }
4932
+ const commonState = useCommonState();
4933
+ const defaultColors = [
4934
+ '#ff8d45',
4935
+ '#ffdf14',
4936
+ '#5eec75',
4937
+ '#5dfaff',
4938
+ '#1296db',
4939
+ '#617fff',
4940
+ '#c459ff',
4941
+ ];
4942
+ return () => {
4943
+ const disabled = commonState().readonly || commonState().inSourceCode || commonState().selectEmbed;
4944
+ return (jsxRuntime.jsx(Dropdown, { arrow: !props.children, width: '177px', style: props.style, disabled: disabled, abreast: props.abreast, menu: jsxRuntime.jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: props.children || jsxRuntime.jsx(Button, { onClick: setCurrentColor, disabled: disabled, children: jsxRuntime.jsx("span", { style: {
4945
+ color: disabled ? '' : color()
4946
+ }, class: "xnote-icon-color" }) }) }));
4947
+ };
4948
+ }
4949
+
4944
4950
  function UnderlineTool() {
4945
4951
  const query = core.inject(core$1.Query);
4946
4952
  const refreshService = core.inject(exports.RefreshService);
@@ -5099,8 +5105,9 @@ function CellAlignTool() {
5099
5105
  core.onUnmounted(() => {
5100
5106
  subscription.unsubscribe();
5101
5107
  });
5108
+ const commonState = useCommonState();
5102
5109
  return () => {
5103
- return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: [
5110
+ return (jsxRuntime.jsx(Dropdown, { disabled: commonState().readonly || commonState().inSourceCode, onCheck: check, menu: [
5104
5111
  {
5105
5112
  label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'top', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-top" }), children: "\u9876\u90E8\u5BF9\u9F50" }),
5106
5113
  value: 'top'
@@ -5113,7 +5120,7 @@ function CellAlignTool() {
5113
5120
  label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'bottom', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-bottom" }), children: "\u5E95\u90E8\u5BF9\u9F50" }),
5114
5121
  value: 'bottom'
5115
5122
  }
5116
- ], children: jsxRuntime.jsx(Button, { arrow: true, highlight: highlight(), children: jsxRuntime.jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
5123
+ ], children: jsxRuntime.jsx(Button, { arrow: true, disabled: commonState().readonly || commonState().inSourceCode, highlight: highlight(), children: jsxRuntime.jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
5117
5124
  };
5118
5125
  }
5119
5126
 
@@ -5155,7 +5162,6 @@ function CellBackgroundTool() {
5155
5162
  const refreshService = core.inject(exports.RefreshService);
5156
5163
  const selection = core.inject(core$1.Selection);
5157
5164
  const [viewModel, update] = hooks.useProduce({
5158
- highlight: false,
5159
5165
  disabled: false,
5160
5166
  });
5161
5167
  function setColor(picker) {
@@ -5203,9 +5209,20 @@ function CellBackgroundTool() {
5203
5209
  core.onUnmounted(() => {
5204
5210
  sub.unsubscribe();
5205
5211
  });
5212
+ const commonState = useCommonState();
5213
+ const defaultColors = [
5214
+ '#ef7373',
5215
+ '#ec9c6a',
5216
+ '#dccc64',
5217
+ '#96e3a3',
5218
+ '#a1e2e3',
5219
+ '#90a0e5',
5220
+ '#c596e0',
5221
+ ];
5206
5222
  return () => {
5207
5223
  const vm = viewModel();
5208
- return (jsxRuntime.jsx(Dropdown, { width: '177px', menu: jsxRuntime.jsx(ColorPicker, { onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
5224
+ const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
5225
+ return (jsxRuntime.jsx(Dropdown, { width: '177px', disabled: d, menu: jsxRuntime.jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { disabled: d, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
5209
5226
  };
5210
5227
  }
5211
5228
 
@@ -5239,9 +5256,10 @@ function MergeCellsTool() {
5239
5256
  core.onUnmounted(() => {
5240
5257
  sub.unsubscribe();
5241
5258
  });
5259
+ const commonState = useCommonState();
5242
5260
  return () => {
5243
5261
  const vm = viewModel();
5244
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
5262
+ return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
5245
5263
  };
5246
5264
  }
5247
5265
 
@@ -5310,9 +5328,10 @@ function SplitCellsTool() {
5310
5328
  core.onUnmounted(() => {
5311
5329
  sub.unsubscribe();
5312
5330
  });
5331
+ const commonState = useCommonState();
5313
5332
  return () => {
5314
5333
  const vm = viewModel();
5315
- return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
5334
+ return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
5316
5335
  };
5317
5336
  }
5318
5337
 
@@ -5416,13 +5435,7 @@ const LeftToolbar = core.withAnnotation({
5416
5435
  return;
5417
5436
  }
5418
5437
  refreshService.onRefresh.next();
5419
- }).add(selection.onChange.pipe(core$1.throttleTime(30)).subscribe(() => {
5420
- if (!selection.isCollapsed) {
5421
- updatePosition(draft => {
5422
- draft.display = false;
5423
- });
5424
- }
5425
- }));
5438
+ });
5426
5439
  core.onUnmounted(() => {
5427
5440
  subscription.unsubscribe();
5428
5441
  });
@@ -5522,7 +5535,7 @@ const LeftToolbar = core.withAnnotation({
5522
5535
  return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
5523
5536
  left: position.left + 'px',
5524
5537
  top: position.top + 'px',
5525
- display: position.display && selection.isCollapsed && editorService.canShowLeftToolbar ? 'block' : 'none'
5538
+ display: position.display && editorService.canShowLeftToolbar ? 'block' : 'none'
5526
5539
  }, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
5527
5540
  position: 'absolute',
5528
5541
  right: 0,
@@ -5530,7 +5543,7 @@ const LeftToolbar = core.withAnnotation({
5530
5543
  }, menu: isEmptyBlock() ?
5531
5544
  jsxRuntime.jsx(InsertMenu, { replace: !needInsert, slot: activeSlot() })
5532
5545
  :
5533
- 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(InsertMenu, { 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() ?
5546
+ 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(TextColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-color" }), children: "\u6587\u672C\u989C\u8272" }) }), jsxRuntime.jsx(TextBackgroundColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-background-color" }), children: "\u6587\u672C\u80CC\u666F\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(InsertMenu, { 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() ?
5534
5547
  jsxRuntime.jsx("span", { children: jsxRuntime.jsx("i", { class: "xnote-icon-plus" }) })
5535
5548
  :
5536
5549
  jsxRuntime.jsxs("span", { children: [activeNode, jsxRuntime.jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
@@ -5642,8 +5655,12 @@ const InlineToolbar = core.withAnnotation({
5642
5655
  const textbus = core.inject(core$1.Textbus);
5643
5656
  const editorService = core.inject(exports.EditorService);
5644
5657
  const refreshService = core.inject(exports.RefreshService);
5645
- const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20)).subscribe(() => {
5658
+ const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20), core$1.tap(() => {
5646
5659
  refreshService.onRefresh.next();
5660
+ }), core$1.delay(200)).subscribe(() => {
5661
+ if (viewPosition().isHide) {
5662
+ editorService.changeLeftToolbarVisible(true);
5663
+ }
5647
5664
  });
5648
5665
  core.onUnmounted(() => {
5649
5666
  subscription.unsubscribe();
@@ -5720,12 +5737,14 @@ const InlineToolbar = core.withAnnotation({
5720
5737
  const sub = textbus.onChange.pipe(core$1.debounceTime(100)).subscribe(() => {
5721
5738
  if (!viewPosition().isHide) {
5722
5739
  const top = getTop();
5723
- if (top !== null) {
5740
+ if (top !== null && !selection.isCollapsed) {
5724
5741
  updateViewPosition(draft => {
5725
5742
  draft.top = top;
5726
5743
  });
5744
+ return;
5727
5745
  }
5728
5746
  }
5747
+ editorService.changeLeftToolbarVisible(true);
5729
5748
  });
5730
5749
  core.onUnmounted(() => {
5731
5750
  sub.unsubscribe();
@@ -5749,6 +5768,10 @@ const InlineToolbar = core.withAnnotation({
5749
5768
  draft.opacity = 1;
5750
5769
  draft.top = top;
5751
5770
  });
5771
+ editorService.changeLeftToolbarVisible(false);
5772
+ }
5773
+ else {
5774
+ editorService.changeLeftToolbarVisible(true);
5752
5775
  }
5753
5776
  });
5754
5777
  }
@@ -5782,7 +5805,7 @@ const InlineToolbar = core.withAnnotation({
5782
5805
  opacity: p.opacity,
5783
5806
  display: editorService.hideInlineToolbar ? 'none' : '',
5784
5807
  transitionDuration: p.transitionDuration + 's'
5785
- }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5808
+ }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5786
5809
  });
5787
5810
  });
5788
5811
 
@@ -5830,7 +5853,7 @@ const StaticToolbar = core.withAnnotation({
5830
5853
  subscription.unsubscribe();
5831
5854
  });
5832
5855
  return scopedCss.withScopedCSS(scopedId$7, () => {
5833
- return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5856
+ return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5834
5857
  });
5835
5858
  });
5836
5859
 
@@ -5912,7 +5935,7 @@ const SuspensionToolbar = core.withAnnotation({
5912
5935
  top: s.top + 'px',
5913
5936
  opacity: s.opacity,
5914
5937
  pointerEvents: s.opacity === 0 ? 'none' : 'initial',
5915
- }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5938
+ }, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
5916
5939
  });
5917
5940
  });
5918
5941
 
@@ -7556,7 +7579,6 @@ exports.CellBackgroundTool = CellBackgroundTool;
7556
7579
  exports.CleanFormatsTool = CleanFormatsTool;
7557
7580
  exports.CodeTool = CodeTool;
7558
7581
  exports.ColorPicker = ColorPicker;
7559
- exports.ColorTool = ColorTool;
7560
7582
  exports.ComponentToolbar = ComponentToolbar;
7561
7583
  exports.Divider = Divider;
7562
7584
  exports.DragResize = DragResize;
@@ -7611,6 +7633,8 @@ exports.SuspensionToolbar = SuspensionToolbar;
7611
7633
  exports.SuspensionToolbarPlugin = SuspensionToolbarPlugin;
7612
7634
  exports.TableComponent = TableComponent;
7613
7635
  exports.TableComponentView = TableComponentView;
7636
+ exports.TextBackgroundColorTool = TextBackgroundColorTool;
7637
+ exports.TextColorTool = TextColorTool;
7614
7638
  exports.TodolistComponent = TodolistComponent;
7615
7639
  exports.TodolistView = TodolistView;
7616
7640
  exports.ToolbarItem = ToolbarItem;