@textbus/xnote 0.3.8 → 1.0.0

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
@@ -7,13 +7,14 @@ var core$1 = require('@textbus/core');
7
7
  var color = require('@tanbo/color');
8
8
  var platformBrowser = require('@textbus/platform-browser');
9
9
  var platformBrowser$1 = require('@viewfly/platform-browser');
10
+ var MarkdownIt = require('markdown-it');
10
11
  var highlightjs = require('highlight.js');
11
12
  var uuid = require('uuid');
12
13
  var Katex = require('katex');
13
14
  var adapterViewfly = require('@textbus/adapter-viewfly');
14
15
  var collaborate = require('@textbus/collaborate');
15
16
 
16
- var scopedId$q = "vf-7d288d";
17
+ var scopedId$r = "vf-7d288d";
17
18
 
18
19
  /******************************************************************************
19
20
  Copyright (c) Microsoft Corporation.
@@ -203,7 +204,7 @@ function Button(props) {
203
204
  subscription.unsubscribe();
204
205
  });
205
206
  }
206
- return scopedCss.withScopedCSS(scopedId$q, () => {
207
+ return scopedCss.withScopedCSS(scopedId$r, () => {
207
208
  return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
208
209
  'btn',
209
210
  {
@@ -215,7 +216,7 @@ function Button(props) {
215
216
  });
216
217
  }
217
218
 
218
- var scopedId$p = "vf-d552b9";
219
+ var scopedId$q = "vf-d552b9";
219
220
 
220
221
  class Picker {
221
222
  set hex(color$1) {
@@ -544,7 +545,7 @@ function ColorPicker(props) {
544
545
  props.onSelected(picker);
545
546
  addRecentColor();
546
547
  }
547
- return scopedCss.withScopedCSS(scopedId$p, () => {
548
+ return scopedCss.withScopedCSS(scopedId$q, () => {
548
549
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
549
550
  return (jsxRuntime.jsxs("div", { onMousedown: ev => {
550
551
  ev.stopPropagation();
@@ -595,10 +596,10 @@ function ColorPicker(props) {
595
596
  });
596
597
  }
597
598
 
598
- var scopedId$o = "vf-ac7e8d";
599
+ var scopedId$p = "vf-ac7e8d";
599
600
 
600
601
  function ComponentToolbar(props) {
601
- return scopedCss.withScopedCSS(scopedId$o, () => {
602
+ return scopedCss.withScopedCSS(scopedId$p, () => {
602
603
  return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
603
604
  'toolbar',
604
605
  {
@@ -608,15 +609,15 @@ function ComponentToolbar(props) {
608
609
  });
609
610
  }
610
611
 
611
- var scopedId$n = "vf-ede279";
612
+ var scopedId$o = "vf-ede279";
612
613
 
613
614
  function Divider() {
614
- return scopedCss.withScopedCSS(scopedId$n, () => {
615
+ return scopedCss.withScopedCSS(scopedId$o, () => {
615
616
  return jsxRuntime.jsx("div", { class: "divider" });
616
617
  });
617
618
  }
618
619
 
619
- var scopedId$m = "vf-d91ad6";
620
+ var scopedId$n = "vf-d91ad6";
620
621
 
621
622
  function DragResize(props) {
622
623
  const isShow = core.createSignal(false);
@@ -725,16 +726,16 @@ function DragResize(props) {
725
726
  });
726
727
  }
727
728
  const sizeText = core.createSignal(`${component.state.width}*${component.state.height}`);
728
- return scopedCss.withScopedCSS(scopedId$m, () => {
729
+ return scopedCss.withScopedCSS(scopedId$n, () => {
729
730
  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', {
730
731
  active: isShow()
731
732
  }], 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" })] })] })] }));
732
733
  });
733
734
  }
734
735
 
735
- var scopedId$l = "vf-0fd06a";
736
+ var scopedId$m = "vf-0fd06a";
736
737
 
737
- var scopedId$k = "vf-8a05e9";
738
+ var scopedId$l = "vf-8a05e9";
738
739
 
739
740
  const DropdownMenuContainer = new core.InjectionToken('DropdownMenuContainer');
740
741
  const DropdownMenuPortal = core.withAnnotation({
@@ -839,7 +840,7 @@ const DropdownMenuPortal = core.withAnnotation({
839
840
  function stopPropagation(ev) {
840
841
  ev.stopPropagation();
841
842
  }
842
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$k, () => {
843
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$l, () => {
843
844
  return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMousedown: stopPropagation, onMouseleave: onLeave, ref: menuRef, style: {
844
845
  width: props.width
845
846
  }, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
@@ -918,7 +919,7 @@ const Dropdown = core.withAnnotation({
918
919
  dropdownContextService.hide(false);
919
920
  }
920
921
  },
921
- $render: scopedCss.withScopedCSS(scopedId$l, () => {
922
+ $render: scopedCss.withScopedCSS(scopedId$m, () => {
922
923
  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', {
923
924
  'has-arrow': props.arrow
924
925
  }], children: props.children }), props.arrow && jsxRuntime.jsx("div", { ref: arrowRef, class: "dropdown-btn-arrow", children: jsxRuntime.jsx(Button, { disabled: props.disabled, arrow: true }) })] }), isShow() &&
@@ -937,7 +938,7 @@ const Dropdown = core.withAnnotation({
937
938
  };
938
939
  });
939
940
 
940
- var scopedId$j = "vf-c32a7b";
941
+ var scopedId$k = "vf-c32a7b";
941
942
 
942
943
  function Keymap(props) {
943
944
  const arr = [];
@@ -971,20 +972,20 @@ function Keymap(props) {
971
972
  arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
972
973
  }
973
974
  }
974
- return scopedCss.withScopedCSS(scopedId$j, () => {
975
+ return scopedCss.withScopedCSS(scopedId$k, () => {
975
976
  return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
976
977
  });
977
978
  }
978
979
 
979
- var scopedId$i = "vf-acaa5f";
980
+ var scopedId$j = "vf-acaa5f";
980
981
 
981
982
  function MenuHeading(props) {
982
- return scopedCss.withScopedCSS(scopedId$i, () => {
983
+ return scopedCss.withScopedCSS(scopedId$j, () => {
983
984
  return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
984
985
  });
985
986
  }
986
987
 
987
- var scopedId$h = "vf-c3b9dc";
988
+ var scopedId$i = "vf-c3b9dc";
988
989
 
989
990
  function MenuItem(props) {
990
991
  const dropdownContextService = core.inject(exports.DropdownContextService, null);
@@ -1004,7 +1005,7 @@ function MenuItem(props) {
1004
1005
  }
1005
1006
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
1006
1007
  }
1007
- return scopedCss.withScopedCSS(scopedId$h, () => {
1008
+ return scopedCss.withScopedCSS(scopedId$i, () => {
1008
1009
  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 ?
1009
1010
  jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
1010
1011
  jsxRuntime.jsx("div", { class: [
@@ -1014,11 +1015,11 @@ function MenuItem(props) {
1014
1015
  });
1015
1016
  }
1016
1017
 
1017
- var scopedId$g = "vf-a23c47";
1018
+ var scopedId$h = "vf-a23c47";
1018
1019
 
1019
1020
  function Popup(props) {
1020
1021
  const host = core.inject(platformBrowser.VIEW_CONTAINER);
1021
- return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$g, () => {
1022
+ return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$h, () => {
1022
1023
  return (jsxRuntime.jsx("div", { class: "popup", style: {
1023
1024
  left: props.left + 'px',
1024
1025
  top: props.top + 'px'
@@ -1026,65 +1027,47 @@ function Popup(props) {
1026
1027
  }), host);
1027
1028
  }
1028
1029
 
1029
- var scopedId$f = "vf-b7a2c8";
1030
+ var scopedId$g = "vf-b7a2c8";
1030
1031
 
1031
1032
  function ToolbarItem(props) {
1032
- return scopedCss.withScopedCSS(scopedId$f, () => {
1033
+ return scopedCss.withScopedCSS(scopedId$g, () => {
1033
1034
  return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
1034
1035
  });
1035
1036
  }
1036
1037
 
1037
- var scopedId$e = "vf-2a8a65";
1038
+ var scopedId$f = "vf-93d3ba";
1038
1039
 
1039
- exports.RefreshService = class RefreshService {
1040
+ exports.EditorService = class EditorService {
1040
1041
  constructor() {
1041
- Object.defineProperty(this, "onRefresh", {
1042
+ Object.defineProperty(this, "hideInlineToolbar", {
1043
+ enumerable: true,
1044
+ configurable: true,
1045
+ writable: true,
1046
+ value: false
1047
+ });
1048
+ Object.defineProperty(this, "canShowLeftToolbar", {
1049
+ enumerable: true,
1050
+ configurable: true,
1051
+ writable: true,
1052
+ value: true
1053
+ });
1054
+ Object.defineProperty(this, "onLeftToolbarCanVisibleChange", {
1042
1055
  enumerable: true,
1043
1056
  configurable: true,
1044
1057
  writable: true,
1045
1058
  value: new core$1.Subject()
1046
1059
  });
1047
1060
  }
1048
- };
1049
- exports.RefreshService = __decorate([
1050
- core.Injectable()
1051
- ], exports.RefreshService);
1052
-
1053
- const textAlignAttr = new core$1.Attribute('textAlign', {
1054
- render(node, formatValue) {
1055
- node.styles.set('text-align', formatValue);
1056
- }
1057
- });
1058
- const textAlignAttrLoader = {
1059
- match(element) {
1060
- return !!element.style.textAlign;
1061
- },
1062
- read(element) {
1063
- return {
1064
- attribute: textAlignAttr,
1065
- value: element.style.textAlign
1066
- };
1061
+ changeLeftToolbarVisible(b) {
1062
+ this.canShowLeftToolbar = b;
1063
+ this.onLeftToolbarCanVisibleChange.next();
1067
1064
  }
1068
1065
  };
1069
- function registerTextAlignShortcut(textbus) {
1070
- const keyboard = textbus.get(core$1.Keyboard);
1071
- const commander = textbus.get(core$1.Commander);
1072
- keyboard.addShortcut({
1073
- keymap: {
1074
- key: 'lrej'.split(''),
1075
- modKey: true
1076
- },
1077
- action(key) {
1078
- const valueMap = {
1079
- l: 'left',
1080
- r: 'right',
1081
- e: 'center',
1082
- j: 'justify'
1083
- };
1084
- commander.applyAttribute(textAlignAttr, valueMap[key]);
1085
- }
1086
- });
1087
- }
1066
+ exports.EditorService = __decorate([
1067
+ core.Injectable({
1068
+ provideIn: 'root'
1069
+ })
1070
+ ], exports.EditorService);
1088
1071
 
1089
1072
  function useReadonly() {
1090
1073
  const controller = core.inject(core$1.Controller);
@@ -1101,6 +1084,110 @@ function useOutput() {
1101
1084
  return core.createSignal(core.inject(OutputInjectionToken));
1102
1085
  }
1103
1086
 
1087
+ class ImageComponent extends core$1.Component {
1088
+ static fromJSON(textbus, json) {
1089
+ return new ImageComponent(Object.assign({}, json));
1090
+ }
1091
+ getSlots() {
1092
+ return [];
1093
+ }
1094
+ }
1095
+ Object.defineProperty(ImageComponent, "type", {
1096
+ enumerable: true,
1097
+ configurable: true,
1098
+ writable: true,
1099
+ value: core$1.ContentType.InlineComponent
1100
+ });
1101
+ Object.defineProperty(ImageComponent, "componentName", {
1102
+ enumerable: true,
1103
+ configurable: true,
1104
+ writable: true,
1105
+ value: 'ImageComponent'
1106
+ });
1107
+ function ImageView(props) {
1108
+ const { name, state } = props.component;
1109
+ const imageRef = core.createRef();
1110
+ const readonly = useReadonly();
1111
+ const output = useOutput();
1112
+ return () => {
1113
+ if (readonly() || output()) {
1114
+ return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
1115
+ width: state.width,
1116
+ height: state.height
1117
+ } }) }));
1118
+ }
1119
+ 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: {
1120
+ width: state.width,
1121
+ height: state.height
1122
+ } }) }) }));
1123
+ };
1124
+ }
1125
+ const imageComponentLoader = {
1126
+ match(element) {
1127
+ return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
1128
+ },
1129
+ read(element) {
1130
+ const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
1131
+ return new ImageComponent({
1132
+ src: img.src,
1133
+ width: img.style.width || 'auto',
1134
+ height: img.style.height || 'auto'
1135
+ });
1136
+ }
1137
+ };
1138
+
1139
+ class VideoComponent extends core$1.Component {
1140
+ static fromJSON(_, json) {
1141
+ return new VideoComponent(Object.assign({}, json));
1142
+ }
1143
+ getSlots() {
1144
+ return [];
1145
+ }
1146
+ }
1147
+ Object.defineProperty(VideoComponent, "type", {
1148
+ enumerable: true,
1149
+ configurable: true,
1150
+ writable: true,
1151
+ value: core$1.ContentType.InlineComponent
1152
+ });
1153
+ Object.defineProperty(VideoComponent, "componentName", {
1154
+ enumerable: true,
1155
+ configurable: true,
1156
+ writable: true,
1157
+ value: 'VideoComponent'
1158
+ });
1159
+ function VideoView(props) {
1160
+ const { name, state } = props.component;
1161
+ const videoRef = core.createRef();
1162
+ const readonly = useReadonly();
1163
+ const output = useOutput();
1164
+ return () => {
1165
+ if (readonly() || output()) {
1166
+ return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
1167
+ width: state.width,
1168
+ height: state.height
1169
+ } }) }));
1170
+ }
1171
+ 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: {
1172
+ width: state.width,
1173
+ height: state.height
1174
+ } }) }) }));
1175
+ };
1176
+ }
1177
+ const videoComponentLoader = {
1178
+ match(element) {
1179
+ return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
1180
+ },
1181
+ read(element) {
1182
+ const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
1183
+ return new VideoComponent({
1184
+ src: video.src,
1185
+ width: video.style.width || 'auto',
1186
+ height: video.style.height || 'auto'
1187
+ });
1188
+ }
1189
+ };
1190
+
1104
1191
  const headingAttr = new core$1.Attribute('Heading', {
1105
1192
  render(node, formatValue) {
1106
1193
  node.classes.add('xnote-' + formatValue);
@@ -1184,6 +1271,89 @@ function useBlockContent(slot) {
1184
1271
  });
1185
1272
  }
1186
1273
 
1274
+ const textIndentAttr = new core$1.Attribute('textIndent', {
1275
+ render(node, formatValue) {
1276
+ return node.styles.set('text-indent', formatValue * 24 + 'px');
1277
+ }
1278
+ });
1279
+ const textIndentAttrLoader = {
1280
+ match(element) {
1281
+ return !!element.style.textIndent;
1282
+ },
1283
+ read(element) {
1284
+ return {
1285
+ attribute: textIndentAttr,
1286
+ value: (parseInt(element.style.textIndent) || 0) / 24
1287
+ };
1288
+ }
1289
+ };
1290
+ function registerTextIndentShortcut(textbus) {
1291
+ const keyboard = textbus.get(core$1.Keyboard);
1292
+ const selection = textbus.get(core$1.Selection);
1293
+ const commander = textbus.get(core$1.Commander);
1294
+ keyboard.addShortcut({
1295
+ keymap: {
1296
+ key: 'Tab',
1297
+ },
1298
+ action() {
1299
+ const blocks = selection.getBlocks();
1300
+ blocks.forEach(block => {
1301
+ if (block.slot.parent instanceof SourceCodeComponent) {
1302
+ return;
1303
+ }
1304
+ const currentIndent = block.slot.getAttribute(textIndentAttr);
1305
+ if (typeof currentIndent === 'number') {
1306
+ block.slot.setAttribute(textIndentAttr, currentIndent + 1);
1307
+ }
1308
+ else {
1309
+ block.slot.setAttribute(textIndentAttr, 1);
1310
+ }
1311
+ });
1312
+ }
1313
+ });
1314
+ keyboard.addShortcut({
1315
+ keymap: {
1316
+ key: 'Tab',
1317
+ shiftKey: true,
1318
+ },
1319
+ action() {
1320
+ const blocks = selection.getBlocks();
1321
+ blocks.forEach(block => {
1322
+ const currentIndent = block.slot.getAttribute(textIndentAttr);
1323
+ if (typeof currentIndent === 'number' && currentIndent > 1) {
1324
+ block.slot.setAttribute(textIndentAttr, currentIndent - 1);
1325
+ }
1326
+ else {
1327
+ block.slot.removeAttribute(textIndentAttr);
1328
+ }
1329
+ });
1330
+ }
1331
+ });
1332
+ keyboard.addShortcut({
1333
+ keymap: {
1334
+ key: 'Backspace'
1335
+ },
1336
+ action() {
1337
+ if (!selection.isCollapsed) {
1338
+ return false;
1339
+ }
1340
+ const slot = selection.commonAncestorSlot;
1341
+ const currentIndent = slot.getAttribute(textIndentAttr);
1342
+ if (typeof currentIndent === 'number' && selection.startOffset === 0) {
1343
+ if (currentIndent > 1) {
1344
+ slot.setAttribute(textIndentAttr, currentIndent - 1);
1345
+ }
1346
+ else {
1347
+ slot.removeAttribute(textIndentAttr);
1348
+ }
1349
+ }
1350
+ else {
1351
+ commander.delete(true);
1352
+ }
1353
+ }
1354
+ });
1355
+ }
1356
+
1187
1357
  function SlotRender(props) {
1188
1358
  const adapter = core.inject(platformBrowser.DomAdapter);
1189
1359
  const instance = core.getCurrentInstance();
@@ -2359,241 +2529,352 @@ const sourceCodeComponentLoader = {
2359
2529
  },
2360
2530
  };
2361
2531
 
2362
- const textIndentAttr = new core$1.Attribute('textIndent', {
2363
- render(node, formatValue) {
2364
- return node.styles.set('text-indent', formatValue * 24 + 'px');
2365
- }
2366
- });
2367
- const textIndentAttrLoader = {
2368
- match(element) {
2369
- return !!element.style.textIndent;
2370
- },
2371
- read(element) {
2372
- return {
2373
- attribute: textIndentAttr,
2374
- value: (parseInt(element.style.textIndent) || 0) / 24
2375
- };
2376
- }
2377
- };
2378
- function registerTextIndentShortcut(textbus) {
2379
- const keyboard = textbus.get(core$1.Keyboard);
2380
- const selection = textbus.get(core$1.Selection);
2381
- const commander = textbus.get(core$1.Commander);
2382
- keyboard.addShortcut({
2383
- keymap: {
2384
- key: 'Tab',
2385
- },
2386
- action() {
2387
- const blocks = selection.getBlocks();
2388
- blocks.forEach(block => {
2389
- if (block.slot.parent instanceof SourceCodeComponent) {
2390
- return;
2391
- }
2392
- const currentIndent = block.slot.getAttribute(textIndentAttr);
2393
- if (typeof currentIndent === 'number') {
2394
- block.slot.setAttribute(textIndentAttr, currentIndent + 1);
2395
- }
2396
- else {
2397
- block.slot.setAttribute(textIndentAttr, 1);
2398
- }
2399
- });
2400
- }
2401
- });
2402
- keyboard.addShortcut({
2403
- keymap: {
2404
- key: 'Tab',
2405
- shiftKey: true,
2406
- },
2407
- action() {
2408
- const blocks = selection.getBlocks();
2409
- blocks.forEach(block => {
2410
- const currentIndent = block.slot.getAttribute(textIndentAttr);
2411
- if (typeof currentIndent === 'number' && currentIndent > 1) {
2412
- block.slot.setAttribute(textIndentAttr, currentIndent - 1);
2413
- }
2414
- else {
2415
- block.slot.removeAttribute(textIndentAttr);
2416
- }
2417
- });
2418
- }
2419
- });
2420
- keyboard.addShortcut({
2421
- keymap: {
2422
- key: 'Backspace'
2423
- },
2424
- action() {
2425
- if (!selection.isCollapsed) {
2426
- return false;
2427
- }
2428
- const slot = selection.commonAncestorSlot;
2429
- const currentIndent = slot.getAttribute(textIndentAttr);
2430
- if (typeof currentIndent === 'number' && selection.startOffset === 0) {
2431
- if (currentIndent > 1) {
2432
- slot.setAttribute(textIndentAttr, currentIndent - 1);
2433
- }
2434
- else {
2435
- slot.removeAttribute(textIndentAttr);
2532
+ let ToolService = class ToolService {
2533
+ constructor(selection, controller) {
2534
+ Object.defineProperty(this, "state", {
2535
+ enumerable: true,
2536
+ configurable: true,
2537
+ writable: true,
2538
+ value: void 0
2539
+ });
2540
+ Object.defineProperty(this, "sub", {
2541
+ enumerable: true,
2542
+ configurable: true,
2543
+ writable: true,
2544
+ value: void 0
2545
+ });
2546
+ this.state = core.createSignal({
2547
+ inSourceCode: false,
2548
+ readonly: controller.readonly,
2549
+ selectEmbed: false,
2550
+ });
2551
+ this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2552
+ const { startSlot, endSlot, startOffset, endOffset } = selection;
2553
+ let is = false;
2554
+ if (startSlot && startSlot === endSlot && endOffset - startOffset === 1) {
2555
+ const component = startSlot.getContentAtIndex(startOffset);
2556
+ if (component instanceof VideoComponent || component instanceof ImageComponent) {
2557
+ is = true;
2436
2558
  }
2437
2559
  }
2438
- else {
2439
- commander.delete(true);
2560
+ const rawState = this.state();
2561
+ const newState = {
2562
+ selectEmbed: is,
2563
+ readonly: controller.readonly,
2564
+ inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
2565
+ };
2566
+ if (newState.selectEmbed !== rawState.selectEmbed ||
2567
+ newState.readonly !== rawState.readonly ||
2568
+ newState.inSourceCode !== rawState.inSourceCode) {
2569
+ this.state.set(newState);
2440
2570
  }
2441
- }
2442
- });
2443
- }
2444
-
2445
- class ImageComponent extends core$1.Component {
2446
- static fromJSON(textbus, json) {
2447
- return new ImageComponent(Object.assign({}, json));
2448
- }
2449
- getSlots() {
2450
- return [];
2451
- }
2452
- }
2453
- Object.defineProperty(ImageComponent, "type", {
2454
- enumerable: true,
2455
- configurable: true,
2456
- writable: true,
2457
- value: core$1.ContentType.InlineComponent
2458
- });
2459
- Object.defineProperty(ImageComponent, "componentName", {
2460
- enumerable: true,
2461
- configurable: true,
2462
- writable: true,
2463
- value: 'ImageComponent'
2464
- });
2465
- function ImageView(props) {
2466
- const { name, state } = props.component;
2467
- const imageRef = core.createRef();
2468
- const readonly = useReadonly();
2469
- const output = useOutput();
2470
- return () => {
2471
- if (readonly() || output()) {
2472
- return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
2473
- width: state.width,
2474
- height: state.height
2475
- } }) }));
2476
- }
2477
- 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: {
2478
- width: state.width,
2479
- height: state.height
2480
- } }) }) }));
2481
- };
2482
- }
2483
- const imageComponentLoader = {
2484
- match(element) {
2485
- return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
2486
- },
2487
- read(element) {
2488
- const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
2489
- return new ImageComponent({
2490
- src: img.src,
2491
- width: img.style.width || 'auto',
2492
- height: img.style.height || 'auto'
2493
2571
  });
2494
2572
  }
2573
+ destroy() {
2574
+ this.sub.unsubscribe();
2575
+ }
2495
2576
  };
2577
+ ToolService = __decorate([
2578
+ core.Injectable(),
2579
+ __metadata("design:paramtypes", [core$1.Selection,
2580
+ core$1.Controller])
2581
+ ], ToolService);
2496
2582
 
2497
- class VideoComponent extends core$1.Component {
2498
- static fromJSON(_, json) {
2499
- return new VideoComponent(Object.assign({}, json));
2500
- }
2501
- getSlots() {
2502
- return [];
2503
- }
2583
+ function useCommonState() {
2584
+ const toolService = core.inject(ToolService);
2585
+ return toolService.state;
2504
2586
  }
2505
- Object.defineProperty(VideoComponent, "type", {
2506
- enumerable: true,
2507
- configurable: true,
2508
- writable: true,
2509
- value: core$1.ContentType.InlineComponent
2510
- });
2511
- Object.defineProperty(VideoComponent, "componentName", {
2512
- enumerable: true,
2513
- configurable: true,
2514
- writable: true,
2515
- value: 'VideoComponent'
2516
- });
2517
- function VideoView(props) {
2518
- const { name, state } = props.component;
2519
- const videoRef = core.createRef();
2520
- const readonly = useReadonly();
2521
- const output = useOutput();
2522
- return () => {
2523
- if (readonly() || output()) {
2524
- return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
2525
- width: state.width,
2526
- height: state.height
2527
- } }) }));
2587
+
2588
+ /**
2589
+ * 大模型接口
2590
+ */
2591
+ class LLMService {
2592
+ }
2593
+
2594
+ function usePopupPosition() {
2595
+ const selectionBridge = core.inject(platformBrowser.SelectionBridge);
2596
+ const container = core.inject(platformBrowser.VIEW_CONTAINER);
2597
+ const selection = core.inject(core$1.Selection);
2598
+ return function (width, height) {
2599
+ const containerRect = container.getBoundingClientRect();
2600
+ const rect = selectionBridge.getRect({
2601
+ slot: selection.focusSlot,
2602
+ offset: selection.focusOffset
2603
+ }) || { left: 0, top: 0, width: 0, height: 0 };
2604
+ let left = rect.left - width / 2;
2605
+ const right = left + width;
2606
+ if (right > containerRect.right) {
2607
+ left = containerRect.right - width;
2528
2608
  }
2529
- 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: {
2530
- width: state.width,
2531
- height: state.height
2532
- } }) }) }));
2609
+ if (left < containerRect.left) {
2610
+ left = containerRect.left;
2611
+ }
2612
+ let top = rect.top - height - 10;
2613
+ if (top < 10) {
2614
+ top = rect.top + rect.height + 10;
2615
+ }
2616
+ return {
2617
+ left: left - containerRect.left,
2618
+ top: top - containerRect.top,
2619
+ };
2533
2620
  };
2534
2621
  }
2535
- const videoComponentLoader = {
2536
- match(element) {
2537
- return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
2538
- },
2539
- read(element) {
2540
- const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
2541
- return new VideoComponent({
2542
- src: video.src,
2543
- width: video.style.width || 'auto',
2544
- height: video.style.height || 'auto'
2622
+
2623
+ function AiTool(props) {
2624
+ const llmService = core.inject(LLMService);
2625
+ const selection = core.inject(core$1.Selection);
2626
+ const commander = core.inject(core$1.Commander);
2627
+ const editorService = core.inject(exports.EditorService);
2628
+ let isClickFromSelf = false;
2629
+ const sub = core$1.fromEvent(document, 'click').subscribe(() => {
2630
+ if (isClickFromSelf) {
2631
+ isClickFromSelf = false;
2632
+ return;
2633
+ }
2634
+ editorService.hideInlineToolbar = false;
2635
+ viewModel.showModal = false;
2636
+ });
2637
+ core.onUnmounted(() => {
2638
+ sub.unsubscribe();
2639
+ });
2640
+ const viewModel = core.reactive({
2641
+ showModal: false,
2642
+ content: '',
2643
+ type: 'translate'
2644
+ });
2645
+ const dropdownRef = core.createRef();
2646
+ let subscription = new core$1.Subscription();
2647
+ function continueContent() {
2648
+ var _a;
2649
+ viewModel.type = 'continue';
2650
+ viewModel.content = '';
2651
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2652
+ viewModel.showModal = true;
2653
+ dropdownRef.current.isShow(false);
2654
+ subscription.unsubscribe();
2655
+ subscription = llmService.continue({
2656
+ text: document.getSelection().toString()
2657
+ }).subscribe((text) => {
2658
+ viewModel.content += text;
2545
2659
  });
2546
2660
  }
2547
- };
2548
-
2549
- let ToolService = class ToolService {
2550
- constructor(selection, controller) {
2551
- Object.defineProperty(this, "state", {
2552
- enumerable: true,
2553
- configurable: true,
2554
- writable: true,
2555
- value: void 0
2661
+ function polish() {
2662
+ var _a;
2663
+ viewModel.type = 'polish';
2664
+ viewModel.content = '';
2665
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2666
+ viewModel.showModal = true;
2667
+ dropdownRef.current.isShow(false);
2668
+ subscription.unsubscribe();
2669
+ subscription = llmService.polish({
2670
+ text: document.getSelection().toString()
2671
+ }).subscribe((text) => {
2672
+ viewModel.content += text;
2556
2673
  });
2557
- Object.defineProperty(this, "sub", {
2558
- enumerable: true,
2559
- configurable: true,
2560
- writable: true,
2561
- value: void 0
2674
+ }
2675
+ function simplify() {
2676
+ var _a;
2677
+ viewModel.type = 'simplify';
2678
+ viewModel.content = '';
2679
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2680
+ viewModel.showModal = true;
2681
+ dropdownRef.current.isShow(false);
2682
+ subscription.unsubscribe();
2683
+ subscription = llmService.simplify({
2684
+ text: document.getSelection().toString()
2685
+ }).subscribe((text) => {
2686
+ viewModel.content += text;
2562
2687
  });
2563
- this.state = core.createSignal({
2564
- inSourceCode: false,
2565
- readonly: controller.readonly,
2566
- selectEmbed: false,
2688
+ }
2689
+ function enrich() {
2690
+ var _a;
2691
+ viewModel.type = 'enrich';
2692
+ viewModel.content = '';
2693
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2694
+ viewModel.showModal = true;
2695
+ dropdownRef.current.isShow(false);
2696
+ subscription.unsubscribe();
2697
+ subscription = llmService.enrich({
2698
+ text: document.getSelection().toString()
2699
+ }).subscribe((text) => {
2700
+ viewModel.content += text;
2567
2701
  });
2568
- this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
2569
- const { startSlot, endSlot, startOffset, endOffset } = selection;
2570
- let is = false;
2571
- if (startSlot && startSlot === endSlot && endOffset - startOffset === 1) {
2572
- const component = startSlot.getContentAtIndex(startOffset);
2573
- if (component instanceof VideoComponent || component instanceof ImageComponent) {
2574
- is = true;
2702
+ }
2703
+ function translate(lang) {
2704
+ var _a;
2705
+ viewModel.type = 'translate';
2706
+ viewModel.content = '';
2707
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2708
+ viewModel.showModal = true;
2709
+ dropdownRef.current.isShow(false);
2710
+ subscription.unsubscribe();
2711
+ subscription = llmService.translate({
2712
+ text: document.getSelection().toString(),
2713
+ targetLanguage: lang
2714
+ }).subscribe((text) => {
2715
+ viewModel.content += text;
2716
+ });
2717
+ }
2718
+ function summarize() {
2719
+ var _a;
2720
+ viewModel.type = 'summarize';
2721
+ viewModel.content = '';
2722
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2723
+ viewModel.showModal = true;
2724
+ dropdownRef.current.isShow(false);
2725
+ subscription.unsubscribe();
2726
+ subscription = llmService.summarize({
2727
+ text: document.getSelection().toString(),
2728
+ }).subscribe((text) => {
2729
+ viewModel.content += text;
2730
+ });
2731
+ }
2732
+ const aiContentRef = core.createRef();
2733
+ const parser = core.inject(platformBrowser.Parser);
2734
+ function insert() {
2735
+ var _a;
2736
+ selection.collapse();
2737
+ aiContentRef.current.childNodes.forEach(node => {
2738
+ const slot = parser.parse(node instanceof HTMLElement ? node : node.textContent || '', new core$1.Slot([
2739
+ core$1.ContentType.BlockComponent,
2740
+ core$1.ContentType.InlineComponent,
2741
+ core$1.ContentType.Text
2742
+ ]));
2743
+ commander.paste(slot, aiContentRef.current.innerText);
2744
+ });
2745
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2746
+ }
2747
+ function replace() {
2748
+ var _a;
2749
+ if (!selection.isCollapsed) {
2750
+ commander.delete();
2751
+ }
2752
+ insert();
2753
+ (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
2754
+ }
2755
+ const md = new MarkdownIt({
2756
+ html: true,
2757
+ breaks: true,
2758
+ linkify: true
2759
+ });
2760
+ function renderMarkdown(markdown) {
2761
+ const html = md.render(markdown);
2762
+ const tempDiv = document.createElement('div');
2763
+ tempDiv.innerHTML = html;
2764
+ function parseNode(node) {
2765
+ if (node.nodeType === Node.TEXT_NODE) {
2766
+ return node.textContent;
2767
+ }
2768
+ if (node.nodeType === Node.ELEMENT_NODE) {
2769
+ const element = node;
2770
+ const TagName = element.tagName.toLowerCase();
2771
+ const children = Array.from(element.childNodes).map(parseNode);
2772
+ const props = {};
2773
+ if (element.className) {
2774
+ props.class = element.className;
2775
+ }
2776
+ switch (TagName) {
2777
+ case 'h1':
2778
+ case 'h2':
2779
+ case 'h3':
2780
+ case 'h4':
2781
+ case 'h5':
2782
+ case 'h6':
2783
+ case 'p':
2784
+ case 'strong':
2785
+ case 'em':
2786
+ case 'code':
2787
+ case 'pre':
2788
+ case 'blockquote':
2789
+ case 'ul':
2790
+ case 'ol':
2791
+ case 'li':
2792
+ case 'span':
2793
+ case 'div':
2794
+ return jsxRuntime.jsx(TagName, Object.assign({}, props, { children: children }));
2795
+ case 'br':
2796
+ return jsxRuntime.jsx("br", {});
2797
+ case 'a':
2798
+ props.href = element.getAttribute('href') || '';
2799
+ return jsxRuntime.jsx("a", Object.assign({}, props, { children: children }));
2800
+ case 'img':
2801
+ props.src = element.getAttribute('src') || '';
2802
+ props.alt = element.getAttribute('alt') || '';
2803
+ return jsxRuntime.jsx("img", Object.assign({}, props));
2804
+ case 'hr':
2805
+ return jsxRuntime.jsx("hr", {});
2806
+ default:
2807
+ return jsxRuntime.jsx("span", Object.assign({}, props, { children: children }));
2575
2808
  }
2576
2809
  }
2577
- this.state.set({
2578
- selectEmbed: is,
2579
- readonly: controller.readonly,
2580
- inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
2581
- });
2582
- });
2810
+ return null;
2811
+ }
2812
+ return Array.from(tempDiv.childNodes).map(parseNode);
2583
2813
  }
2584
- destroy() {
2585
- this.sub.unsubscribe();
2814
+ const commonState = useCommonState();
2815
+ const popupPosition = usePopupPosition();
2816
+ return scopedCss.withScopedCSS(scopedId$f, () => {
2817
+ const rect = popupPosition(400, 210);
2818
+ const b = commonState().inSourceCode || commonState().readonly && !selection.isCollapsed;
2819
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Dropdown, { ref: dropdownRef, disabled: b, width: '160px', menu: !viewModel.showModal ? jsxRuntime.jsxs("div", { onClick: () => isClickFromSelf = true, children: [jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-continuation" }), onClick: continueContent, children: "\u7EED\u5199" }), jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-magic-wand" }), onClick: polish, children: "\u6DA6\u8272" }), jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-simplify" }), onClick: simplify, children: "\u7B80\u5316\u5185\u5BB9" }), jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-enrich" }), onClick: enrich, children: "\u4E30\u5BCC\u5185\u5BB9" }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(Dropdown, { style: {
2820
+ display: 'block'
2821
+ }, abreast: true, menu: jsxRuntime.jsxs("div", { onClick: () => isClickFromSelf = true, children: [jsxRuntime.jsx(MenuItem, { onClick: () => translate('中文'), children: "\u4E2D\u6587" }), jsxRuntime.jsx(MenuItem, { onClick: () => translate('英语'), children: "\u82F1\u8BED" }), jsxRuntime.jsx(MenuItem, { onClick: () => translate('西班牙语'), children: "\u897F\u73ED\u7259\u8BED" }), jsxRuntime.jsx(MenuItem, { onClick: () => translate('日语'), children: "\u65E5\u8BED" })] }), children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-translation" }), children: "\u7FFB\u8BD1" }) }), jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-summary" }), onClick: summarize, children: "\u603B\u7ED3" })] }) : null, children: jsxRuntime.jsx(Button, { arrow: true, disabled: b, children: jsxRuntime.jsx("span", { class: "xnote-icon-ai" }) }) }), viewModel.showModal &&
2822
+ jsxRuntime.jsx(Popup, { left: rect.left, top: rect.top, children: jsxRuntime.jsxs("div", { onClick: () => {
2823
+ isClickFromSelf = true;
2824
+ }, class: "input-group", children: [jsxRuntime.jsx("div", { class: "ai-content", ref: aiContentRef, children: renderMarkdown(viewModel.content) }), jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { type: "button", onClick: replace, children: "\u66FF\u6362" }), jsxRuntime.jsx(Button, { type: "button", onClick: insert, children: "\u63D2\u5165" })] })] }) })] }));
2825
+ });
2826
+ }
2827
+
2828
+ var scopedId$e = "vf-2a8a65";
2829
+
2830
+ exports.RefreshService = class RefreshService {
2831
+ constructor() {
2832
+ Object.defineProperty(this, "onRefresh", {
2833
+ enumerable: true,
2834
+ configurable: true,
2835
+ writable: true,
2836
+ value: new core$1.Subject()
2837
+ });
2586
2838
  }
2587
2839
  };
2588
- ToolService = __decorate([
2589
- core.Injectable(),
2590
- __metadata("design:paramtypes", [core$1.Selection,
2591
- core$1.Controller])
2592
- ], ToolService);
2840
+ exports.RefreshService = __decorate([
2841
+ core.Injectable()
2842
+ ], exports.RefreshService);
2593
2843
 
2594
- function useCommonState() {
2595
- const toolService = core.inject(ToolService);
2596
- return toolService.state;
2844
+ const textAlignAttr = new core$1.Attribute('textAlign', {
2845
+ render(node, formatValue) {
2846
+ node.styles.set('text-align', formatValue);
2847
+ }
2848
+ });
2849
+ const textAlignAttrLoader = {
2850
+ match(element) {
2851
+ return !!element.style.textAlign;
2852
+ },
2853
+ read(element) {
2854
+ return {
2855
+ attribute: textAlignAttr,
2856
+ value: element.style.textAlign
2857
+ };
2858
+ }
2859
+ };
2860
+ function registerTextAlignShortcut(textbus) {
2861
+ const keyboard = textbus.get(core$1.Keyboard);
2862
+ const commander = textbus.get(core$1.Commander);
2863
+ keyboard.addShortcut({
2864
+ keymap: {
2865
+ key: 'lrej'.split(''),
2866
+ modKey: true
2867
+ },
2868
+ action(key) {
2869
+ const valueMap = {
2870
+ l: 'left',
2871
+ r: 'right',
2872
+ e: 'center',
2873
+ j: 'justify'
2874
+ };
2875
+ commander.applyAttribute(textAlignAttr, valueMap[key]);
2876
+ }
2877
+ });
2597
2878
  }
2598
2879
 
2599
2880
  function AttrTool(props) {
@@ -3505,6 +3786,51 @@ const todolistComponentLoader = {
3505
3786
  }
3506
3787
  };
3507
3788
 
3789
+ const underlineFormatter = new core$1.Formatter('underline', {
3790
+ columned: true,
3791
+ render(children) {
3792
+ return core$1.createVNode('u', null, children);
3793
+ }
3794
+ });
3795
+ function toggleUnderline(textbus) {
3796
+ const controller = textbus.get(core$1.Controller);
3797
+ if (controller.readonly) {
3798
+ return;
3799
+ }
3800
+ const query = textbus.get(core$1.Query);
3801
+ const commander = textbus.get(core$1.Commander);
3802
+ const state = query.queryFormat(underlineFormatter);
3803
+ if (state.state === core$1.QueryStateType.Normal) {
3804
+ commander.applyFormat(underlineFormatter, true);
3805
+ }
3806
+ else {
3807
+ commander.unApplyFormat(underlineFormatter);
3808
+ }
3809
+ }
3810
+ function registerUnderlineShortcut(textbus) {
3811
+ const keyboard = textbus.get(core$1.Keyboard);
3812
+ keyboard.addShortcut({
3813
+ keymap: {
3814
+ modKey: true,
3815
+ key: 'u'
3816
+ },
3817
+ action: () => {
3818
+ toggleUnderline(textbus);
3819
+ }
3820
+ });
3821
+ }
3822
+ const underlineFormatLoader = {
3823
+ match(element) {
3824
+ return element.tagName === 'U';
3825
+ },
3826
+ read() {
3827
+ return {
3828
+ formatter: underlineFormatter,
3829
+ value: true
3830
+ };
3831
+ }
3832
+ };
3833
+
3508
3834
  function toList(textbus, type) {
3509
3835
  const commander = textbus.get(core$1.Commander);
3510
3836
  commander.transform({
@@ -3704,6 +4030,7 @@ function numberToLetter(num) {
3704
4030
  }
3705
4031
  function ListComponentView(props) {
3706
4032
  const component = props.component;
4033
+ const adapter = core.inject(platformBrowser.DomAdapter);
3707
4034
  function reorder(is) {
3708
4035
  component.state.reorder = is;
3709
4036
  const parentSlot = component.parent;
@@ -3768,15 +4095,24 @@ function ListComponentView(props) {
3768
4095
  icon = numberToLetter(listStep) + '.';
3769
4096
  }
3770
4097
  }
4098
+ const formatters = component.state.slot.extractFormatsByIndex(0).filter(i => {
4099
+ const formatter = i[0];
4100
+ return formatter !== colorFormatter &&
4101
+ formatter !== underlineFormatter &&
4102
+ formatter !== strikeThroughFormatter;
4103
+ });
4104
+ const iconVEl = core$1.Slot.formatsToTree(formatters, [new core$1.VTextNode(icon)], readonly() || output());
4105
+ const iconEl = iconVEl ? adapter.vElementToViewElement(iconVEl) : icon;
4106
+ const heading = component.state.slot.getAttribute(headingAttr);
3771
4107
  return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, "data-reorder": (listStep === 0) + '', class: "xnote-list", style: {
3772
4108
  marginLeft: indent * 24 + 'px'
3773
- }, children: jsxRuntime.jsxs("li", { style: {
4109
+ }, children: jsxRuntime.jsx("li", { style: {
3774
4110
  justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
3775
- textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
3776
- }, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
3777
- jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
3778
- :
3779
- jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), jsxRuntime.jsx(SlotRender, { slot: component.state.slot, class: "xnote-list-content", renderEnv: readonly() || output() })] }) }));
4111
+ textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0,
4112
+ }, children: jsxRuntime.jsxs("div", { class: ['xnote-list-inner'], children: [jsxRuntime.jsx("div", { class: ['xnote-list-type', heading ? `xnote-${heading}` : ''], children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
4113
+ jsxRuntime.jsx("span", { class: "xnote-order-btn", children: iconEl })
4114
+ :
4115
+ jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit', fontSize: 'inherit', height: 'auto', appearance: 'none', padding: '0' }, children: iconEl }) }) }), jsxRuntime.jsx(SlotRender, { slot: component.state.slot, class: "xnote-list-content", renderEnv: readonly() || output() })] }) }) }));
3780
4116
  };
3781
4117
  }
3782
4118
  const listComponentLoader = {
@@ -3900,6 +4236,11 @@ function useBlockTransform() {
3900
4236
  case 'h4':
3901
4237
  case 'h5':
3902
4238
  case 'h6':
4239
+ selection.getBlocks().forEach((block) => {
4240
+ block.slot.cleanFormats(f => {
4241
+ return f !== fontSizeFormatter;
4242
+ });
4243
+ });
3903
4244
  commander.applyAttribute(headingAttr, value);
3904
4245
  break;
3905
4246
  case 'paragraph':
@@ -4351,51 +4692,6 @@ const superscriptFormatLoader = {
4351
4692
  }
4352
4693
  };
4353
4694
 
4354
- const underlineFormatter = new core$1.Formatter('underline', {
4355
- columned: true,
4356
- render(children) {
4357
- return core$1.createVNode('u', null, children);
4358
- }
4359
- });
4360
- function toggleUnderline(textbus) {
4361
- const controller = textbus.get(core$1.Controller);
4362
- if (controller.readonly) {
4363
- return;
4364
- }
4365
- const query = textbus.get(core$1.Query);
4366
- const commander = textbus.get(core$1.Commander);
4367
- const state = query.queryFormat(underlineFormatter);
4368
- if (state.state === core$1.QueryStateType.Normal) {
4369
- commander.applyFormat(underlineFormatter, true);
4370
- }
4371
- else {
4372
- commander.unApplyFormat(underlineFormatter);
4373
- }
4374
- }
4375
- function registerUnderlineShortcut(textbus) {
4376
- const keyboard = textbus.get(core$1.Keyboard);
4377
- keyboard.addShortcut({
4378
- keymap: {
4379
- modKey: true,
4380
- key: 'u'
4381
- },
4382
- action: () => {
4383
- toggleUnderline(textbus);
4384
- }
4385
- });
4386
- }
4387
- const underlineFormatLoader = {
4388
- match(element) {
4389
- return element.tagName === 'U';
4390
- },
4391
- read() {
4392
- return {
4393
- formatter: underlineFormatter,
4394
- value: true
4395
- };
4396
- }
4397
- };
4398
-
4399
4695
  function BoldTool() {
4400
4696
  const query = core.inject(core$1.Query);
4401
4697
  const textbus = core.inject(core$1.Textbus);
@@ -5008,44 +5304,9 @@ function ItalicTool() {
5008
5304
 
5009
5305
  var scopedId$c = "vf-e74208";
5010
5306
 
5011
- exports.EditorService = class EditorService {
5012
- constructor() {
5013
- Object.defineProperty(this, "hideInlineToolbar", {
5014
- enumerable: true,
5015
- configurable: true,
5016
- writable: true,
5017
- value: false
5018
- });
5019
- Object.defineProperty(this, "canShowLeftToolbar", {
5020
- enumerable: true,
5021
- configurable: true,
5022
- writable: true,
5023
- value: true
5024
- });
5025
- Object.defineProperty(this, "onLeftToolbarCanVisibleChange", {
5026
- enumerable: true,
5027
- configurable: true,
5028
- writable: true,
5029
- value: new core$1.Subject()
5030
- });
5031
- }
5032
- changeLeftToolbarVisible(b) {
5033
- this.canShowLeftToolbar = b;
5034
- this.onLeftToolbarCanVisibleChange.next();
5035
- }
5036
- };
5037
- exports.EditorService = __decorate([
5038
- core.Injectable({
5039
- provideIn: 'root'
5040
- })
5041
- ], exports.EditorService);
5042
-
5043
5307
  function LinkTool(props) {
5044
- const selectionBridge = core.inject(platformBrowser.SelectionBridge);
5045
- const selection = core.inject(core$1.Selection);
5046
5308
  const commander = core.inject(core$1.Commander);
5047
5309
  const editorService = core.inject(exports.EditorService);
5048
- const container = core.inject(platformBrowser.VIEW_CONTAINER);
5049
5310
  const isShow = core.createSignal(false);
5050
5311
  const value = core.createSignal('');
5051
5312
  function setLink(ev) {
@@ -5069,19 +5330,16 @@ function LinkTool(props) {
5069
5330
  sub.unsubscribe();
5070
5331
  });
5071
5332
  const commonState = useCommonState();
5333
+ const popupPosition = usePopupPosition();
5072
5334
  return scopedCss.withScopedCSS(scopedId$c, () => {
5073
- const containerRect = container.getBoundingClientRect();
5074
- const rect = isShow() ? selectionBridge.getRect({
5075
- slot: selection.focusSlot,
5076
- offset: selection.focusOffset
5077
- }) : {};
5335
+ const rect = popupPosition(224, 38);
5078
5336
  return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, onClick: () => {
5079
5337
  var _a;
5080
5338
  isShow.set(true);
5081
5339
  isClickFromSelf = true;
5082
5340
  (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
5083
5341
  }, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
5084
- jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
5342
+ jsxRuntime.jsx(Popup, { left: rect.left, top: rect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
5085
5343
  isClickFromSelf = true;
5086
5344
  }, class: "input-group", children: [jsxRuntime.jsx("input", { onChange: ev => {
5087
5345
  value.set(ev.target.value);
@@ -6134,6 +6392,7 @@ const InlineToolbar = core.withAnnotation({
6134
6392
  mousedownSubscription.unsubscribe();
6135
6393
  mouseupSubscription.unsubscribe();
6136
6394
  });
6395
+ const llmService = core.inject(LLMService, null);
6137
6396
  return scopedCss.withScopedCSS(scopedId$8, () => {
6138
6397
  return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
6139
6398
  left: viewPosition.left + 'px',
@@ -6142,7 +6401,7 @@ const InlineToolbar = core.withAnnotation({
6142
6401
  opacity: viewPosition.opacity,
6143
6402
  display: editorService.hideInlineToolbar ? 'none' : '',
6144
6403
  transitionDuration: viewPosition.transitionDuration + 's'
6145
- }, 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")] }));
6404
+ }, children: [llmService && jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AiTool, { hideToolbar: hideToolbar }) }), 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")] }));
6146
6405
  });
6147
6406
  });
6148
6407
 
@@ -6199,8 +6458,9 @@ const StaticToolbar = core.withAnnotation({
6199
6458
  core.onUnmounted(() => {
6200
6459
  subscription.unsubscribe();
6201
6460
  });
6461
+ const llmService = core.inject(LLMService, null);
6202
6462
  return scopedCss.withScopedCSS(scopedId$7, () => {
6203
- 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")] }));
6463
+ 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, {}), llmService && jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AiTool, {}) }), 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")] }));
6204
6464
  });
6205
6465
  });
6206
6466
 
@@ -6247,7 +6507,7 @@ class StaticToolbarPlugin {
6247
6507
  }
6248
6508
  }
6249
6509
 
6250
- var scopedId$6 = "vf-25fd9c";
6510
+ var scopedId$6 = "vf-927bfc";
6251
6511
 
6252
6512
  const SuspensionToolbar = core.withAnnotation({
6253
6513
  providers: [exports.RefreshService, ToolService]
@@ -6282,14 +6542,15 @@ const SuspensionToolbar = core.withAnnotation({
6282
6542
  }), core$1.delay(100)).subscribe(() => {
6283
6543
  styles.opacity = 1;
6284
6544
  }));
6545
+ const llmService = core.inject(LLMService, null);
6285
6546
  return scopedCss.withScopedCSS(scopedId$6, () => {
6286
- return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme, {
6547
+ return (jsxRuntime.jsx("div", { class: ['toolbar', props.theme, {
6287
6548
  suspension: styles.top === 0 ? '' : 'suspension'
6288
6549
  }], style: {
6289
6550
  top: styles.top + 'px',
6290
6551
  opacity: styles.opacity,
6291
6552
  pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
6292
- }, 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")] }));
6553
+ }, children: jsxRuntime.jsxs("div", { class: "toolbar-tools", children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), llmService && jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AiTool, {}) }), 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")] }) }));
6293
6554
  });
6294
6555
  });
6295
6556
 
@@ -6317,6 +6578,7 @@ class SuspensionToolbarPlugin {
6317
6578
  setup(injector) {
6318
6579
  const host = injector.get(platformBrowser.VIEW_CONTAINER);
6319
6580
  const container = document.createElement('div');
6581
+ container.style.cssText = 'display:flex;justify-content:center;';
6320
6582
  this.app = platformBrowser$1.createApp(jsxRuntime.jsx(SuspensionToolbar, { theme: this.options.theme }), {
6321
6583
  context: injector
6322
6584
  });
@@ -8094,6 +8356,7 @@ class Editor extends core$1.Textbus {
8094
8356
  }
8095
8357
  }
8096
8358
 
8359
+ exports.AiTool = AiTool;
8097
8360
  exports.AtComponent = AtComponent;
8098
8361
  exports.AtComponentView = AtComponentView;
8099
8362
  exports.AttrTool = AttrTool;
@@ -8129,6 +8392,7 @@ exports.ItalicTool = ItalicTool;
8129
8392
  exports.KatexComponent = KatexComponent;
8130
8393
  exports.KatexComponentView = KatexComponentView;
8131
8394
  exports.Keymap = Keymap;
8395
+ exports.LLMService = LLMService;
8132
8396
  exports.LeftToolbar = LeftToolbar;
8133
8397
  exports.LeftToolbarPlugin = LeftToolbarPlugin;
8134
8398
  exports.LinkJump = LinkJump;