@textbus/xnote 0.3.9 → 1.0.1
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/ai.service.ts +124 -0
- package/bundles/fonts/textbus.svg +51 -43
- package/bundles/fonts/textbus.ttf +0 -0
- package/bundles/fonts/textbus.woff +0 -0
- package/bundles/index.css +2 -2
- package/bundles/index.esm.css +2 -2
- package/bundles/index.esm.js +624 -376
- package/bundles/index.js +623 -373
- package/bundles/plugins/hooks/popup-position.d.ts +4 -0
- package/bundles/plugins/tools/_api.d.ts +1 -0
- package/bundles/plugins/tools/ai.tool.d.ts +4 -0
- package/bundles/services/_api.d.ts +1 -0
- package/bundles/services/llm.service.d.ts +24 -0
- package/bundles/textbus/components/table/tools/complete.d.ts +1 -1
- package/index.tsx +10 -4
- package/lerna.json +1 -4
- package/package.json +7 -5
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
599
|
+
var scopedId$p = "vf-ac7e8d";
|
|
599
600
|
|
|
600
601
|
function ComponentToolbar(props) {
|
|
601
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
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$
|
|
612
|
+
var scopedId$o = "vf-ede279";
|
|
612
613
|
|
|
613
614
|
function Divider() {
|
|
614
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
615
|
+
return scopedCss.withScopedCSS(scopedId$o, () => {
|
|
615
616
|
return jsxRuntime.jsx("div", { class: "divider" });
|
|
616
617
|
});
|
|
617
618
|
}
|
|
618
619
|
|
|
619
|
-
var scopedId$
|
|
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$
|
|
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$
|
|
736
|
+
var scopedId$m = "vf-0fd06a";
|
|
736
737
|
|
|
737
|
-
var scopedId$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
980
|
+
var scopedId$j = "vf-acaa5f";
|
|
980
981
|
|
|
981
982
|
function MenuHeading(props) {
|
|
982
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1030
|
+
var scopedId$g = "vf-b7a2c8";
|
|
1030
1031
|
|
|
1031
1032
|
function ToolbarItem(props) {
|
|
1032
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
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$
|
|
1038
|
+
var scopedId$f = "vf-93d3ba";
|
|
1038
1039
|
|
|
1039
|
-
exports.
|
|
1040
|
+
exports.EditorService = class EditorService {
|
|
1040
1041
|
constructor() {
|
|
1041
|
-
Object.defineProperty(this, "
|
|
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
|
-
|
|
1050
|
-
|
|
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
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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();
|
|
@@ -2280,270 +2450,83 @@ function SourceCodeView(props) {
|
|
|
2280
2450
|
children = nodesToVNodes(item.slot, nodes, 0);
|
|
2281
2451
|
if (!children.length) {
|
|
2282
2452
|
const br = core$1.createVNode('br');
|
|
2283
|
-
br.location = {
|
|
2284
|
-
slot: item.slot,
|
|
2285
|
-
startIndex: 0,
|
|
2286
|
-
endIndex: 1
|
|
2287
|
-
};
|
|
2288
|
-
children.push(br);
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
return core$1.createVNode('div', {
|
|
2292
|
-
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
|
|
2293
|
-
key: item.slot.id
|
|
2294
|
-
}, [
|
|
2295
|
-
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
2296
|
-
]);
|
|
2297
|
-
}, readonly());
|
|
2298
|
-
}) }), jsxRuntime.jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
function nodesToVNodes(slot, nodes, index) {
|
|
2302
|
-
return nodes.map(i => {
|
|
2303
|
-
const location = {
|
|
2304
|
-
slot,
|
|
2305
|
-
startIndex: index,
|
|
2306
|
-
endIndex: index + i.textContent.length
|
|
2307
|
-
};
|
|
2308
|
-
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
2309
|
-
const childNodes = Array.from(i.childNodes);
|
|
2310
|
-
const vEle = core$1.createVNode('span', {
|
|
2311
|
-
class: i.className
|
|
2312
|
-
}, nodesToVNodes(slot, childNodes, index));
|
|
2313
|
-
index = location.endIndex;
|
|
2314
|
-
vEle.location = Object.assign({}, location);
|
|
2315
|
-
return vEle;
|
|
2316
|
-
}
|
|
2317
|
-
index = location.endIndex;
|
|
2318
|
-
const textNode = new core$1.VTextNode(i.textContent);
|
|
2319
|
-
textNode.location = location;
|
|
2320
|
-
return textNode;
|
|
2321
|
-
});
|
|
2322
|
-
}
|
|
2323
|
-
const sourceCodeComponentLoader = {
|
|
2324
|
-
match(element, returnableContentTypes) {
|
|
2325
|
-
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
|
|
2326
|
-
((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
|
|
2327
|
-
element.tagName === 'PRE');
|
|
2328
|
-
},
|
|
2329
|
-
read(el) {
|
|
2330
|
-
let slots = [];
|
|
2331
|
-
if (el.tagName === 'DIV') {
|
|
2332
|
-
const lines = el.querySelectorAll('.xnote-source-code-line');
|
|
2333
|
-
slots = Array.from(lines).map(i => {
|
|
2334
|
-
const code = i.innerText.replace(/[\s\n]+$/, '');
|
|
2335
|
-
const item = createCodeSlot();
|
|
2336
|
-
const slot = item.slot;
|
|
2337
|
-
item.emphasize = i.classList.contains('xnote-source-code-line-emphasize');
|
|
2338
|
-
slot.insert(code);
|
|
2339
|
-
return item;
|
|
2340
|
-
});
|
|
2341
|
-
}
|
|
2342
|
-
else {
|
|
2343
|
-
el.querySelectorAll('br').forEach(br => {
|
|
2344
|
-
br.parentNode.replaceChild(document.createTextNode('\n'), br);
|
|
2345
|
-
});
|
|
2346
|
-
slots = el.innerText.split('\n').map(code => {
|
|
2347
|
-
const item = createCodeSlot();
|
|
2348
|
-
item.slot.insert(code);
|
|
2349
|
-
return item;
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
return new SourceCodeComponent({
|
|
2353
|
-
lang: el.dataset.lang || '',
|
|
2354
|
-
theme: el.dataset.theme || '',
|
|
2355
|
-
lineNumber: el.dataset.lineNumber === 'true',
|
|
2356
|
-
autoBreak: el.dataset.autoBreak === 'true',
|
|
2357
|
-
slots
|
|
2358
|
-
});
|
|
2359
|
-
},
|
|
2360
|
-
};
|
|
2361
|
-
|
|
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);
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
else {
|
|
2439
|
-
commander.delete(true);
|
|
2440
|
-
}
|
|
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
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
};
|
|
2496
|
-
|
|
2497
|
-
class VideoComponent extends core$1.Component {
|
|
2498
|
-
static fromJSON(_, json) {
|
|
2499
|
-
return new VideoComponent(Object.assign({}, json));
|
|
2500
|
-
}
|
|
2501
|
-
getSlots() {
|
|
2502
|
-
return [];
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
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
|
-
} }) }));
|
|
2528
|
-
}
|
|
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
|
-
} }) }) }));
|
|
2453
|
+
br.location = {
|
|
2454
|
+
slot: item.slot,
|
|
2455
|
+
startIndex: 0,
|
|
2456
|
+
endIndex: 1
|
|
2457
|
+
};
|
|
2458
|
+
children.push(br);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return core$1.createVNode('div', {
|
|
2462
|
+
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
|
|
2463
|
+
key: item.slot.id
|
|
2464
|
+
}, [
|
|
2465
|
+
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
2466
|
+
]);
|
|
2467
|
+
}, readonly());
|
|
2468
|
+
}) }), jsxRuntime.jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
|
|
2533
2469
|
};
|
|
2534
2470
|
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2471
|
+
function nodesToVNodes(slot, nodes, index) {
|
|
2472
|
+
return nodes.map(i => {
|
|
2473
|
+
const location = {
|
|
2474
|
+
slot,
|
|
2475
|
+
startIndex: index,
|
|
2476
|
+
endIndex: index + i.textContent.length
|
|
2477
|
+
};
|
|
2478
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
2479
|
+
const childNodes = Array.from(i.childNodes);
|
|
2480
|
+
const vEle = core$1.createVNode('span', {
|
|
2481
|
+
class: i.className
|
|
2482
|
+
}, nodesToVNodes(slot, childNodes, index));
|
|
2483
|
+
index = location.endIndex;
|
|
2484
|
+
vEle.location = Object.assign({}, location);
|
|
2485
|
+
return vEle;
|
|
2486
|
+
}
|
|
2487
|
+
index = location.endIndex;
|
|
2488
|
+
const textNode = new core$1.VTextNode(i.textContent);
|
|
2489
|
+
textNode.location = location;
|
|
2490
|
+
return textNode;
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
const sourceCodeComponentLoader = {
|
|
2494
|
+
match(element, returnableContentTypes) {
|
|
2495
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
|
|
2496
|
+
((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
|
|
2497
|
+
element.tagName === 'PRE');
|
|
2538
2498
|
},
|
|
2539
|
-
read(
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2499
|
+
read(el) {
|
|
2500
|
+
let slots = [];
|
|
2501
|
+
if (el.tagName === 'DIV') {
|
|
2502
|
+
const lines = el.querySelectorAll('.xnote-source-code-line');
|
|
2503
|
+
slots = Array.from(lines).map(i => {
|
|
2504
|
+
const code = i.innerText.replace(/[\s\n]+$/, '');
|
|
2505
|
+
const item = createCodeSlot();
|
|
2506
|
+
const slot = item.slot;
|
|
2507
|
+
item.emphasize = i.classList.contains('xnote-source-code-line-emphasize');
|
|
2508
|
+
slot.insert(code);
|
|
2509
|
+
return item;
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
else {
|
|
2513
|
+
el.querySelectorAll('br').forEach(br => {
|
|
2514
|
+
br.parentNode.replaceChild(document.createTextNode('\n'), br);
|
|
2515
|
+
});
|
|
2516
|
+
slots = el.innerText.split('\n').map(code => {
|
|
2517
|
+
const item = createCodeSlot();
|
|
2518
|
+
item.slot.insert(code);
|
|
2519
|
+
return item;
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2522
|
+
return new SourceCodeComponent({
|
|
2523
|
+
lang: el.dataset.lang || '',
|
|
2524
|
+
theme: el.dataset.theme || '',
|
|
2525
|
+
lineNumber: el.dataset.lineNumber === 'true',
|
|
2526
|
+
autoBreak: el.dataset.autoBreak === 'true',
|
|
2527
|
+
slots
|
|
2545
2528
|
});
|
|
2546
|
-
}
|
|
2529
|
+
},
|
|
2547
2530
|
};
|
|
2548
2531
|
|
|
2549
2532
|
let ToolService = class ToolService {
|
|
@@ -2574,11 +2557,17 @@ let ToolService = class ToolService {
|
|
|
2574
2557
|
is = true;
|
|
2575
2558
|
}
|
|
2576
2559
|
}
|
|
2577
|
-
this.state
|
|
2560
|
+
const rawState = this.state();
|
|
2561
|
+
const newState = {
|
|
2578
2562
|
selectEmbed: is,
|
|
2579
2563
|
readonly: controller.readonly,
|
|
2580
2564
|
inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
|
|
2581
|
-
}
|
|
2565
|
+
};
|
|
2566
|
+
if (newState.selectEmbed !== rawState.selectEmbed ||
|
|
2567
|
+
newState.readonly !== rawState.readonly ||
|
|
2568
|
+
newState.inSourceCode !== rawState.inSourceCode) {
|
|
2569
|
+
this.state.set(newState);
|
|
2570
|
+
}
|
|
2582
2571
|
});
|
|
2583
2572
|
}
|
|
2584
2573
|
destroy() {
|
|
@@ -2596,6 +2585,299 @@ function useCommonState() {
|
|
|
2596
2585
|
return toolService.state;
|
|
2597
2586
|
}
|
|
2598
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;
|
|
2608
|
+
}
|
|
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
|
+
};
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
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;
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
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;
|
|
2673
|
+
});
|
|
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;
|
|
2687
|
+
});
|
|
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;
|
|
2701
|
+
});
|
|
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
|
+
viewModel.showModal = false;
|
|
2746
|
+
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
2747
|
+
}
|
|
2748
|
+
function replace() {
|
|
2749
|
+
var _a;
|
|
2750
|
+
if (!selection.isCollapsed) {
|
|
2751
|
+
commander.delete();
|
|
2752
|
+
}
|
|
2753
|
+
insert();
|
|
2754
|
+
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
2755
|
+
}
|
|
2756
|
+
const md = new MarkdownIt({
|
|
2757
|
+
html: true,
|
|
2758
|
+
breaks: true,
|
|
2759
|
+
linkify: true
|
|
2760
|
+
});
|
|
2761
|
+
function renderMarkdown(markdown) {
|
|
2762
|
+
const html = md.render(markdown);
|
|
2763
|
+
const tempDiv = document.createElement('div');
|
|
2764
|
+
tempDiv.innerHTML = html;
|
|
2765
|
+
function parseNode(node) {
|
|
2766
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
2767
|
+
return node.textContent;
|
|
2768
|
+
}
|
|
2769
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2770
|
+
const element = node;
|
|
2771
|
+
const TagName = element.tagName.toLowerCase();
|
|
2772
|
+
const children = Array.from(element.childNodes).map(parseNode);
|
|
2773
|
+
const props = {};
|
|
2774
|
+
if (element.className) {
|
|
2775
|
+
props.class = element.className;
|
|
2776
|
+
}
|
|
2777
|
+
switch (TagName) {
|
|
2778
|
+
case 'h1':
|
|
2779
|
+
case 'h2':
|
|
2780
|
+
case 'h3':
|
|
2781
|
+
case 'h4':
|
|
2782
|
+
case 'h5':
|
|
2783
|
+
case 'h6':
|
|
2784
|
+
case 'p':
|
|
2785
|
+
case 'strong':
|
|
2786
|
+
case 'em':
|
|
2787
|
+
case 'code':
|
|
2788
|
+
case 'pre':
|
|
2789
|
+
case 'blockquote':
|
|
2790
|
+
case 'ul':
|
|
2791
|
+
case 'ol':
|
|
2792
|
+
case 'li':
|
|
2793
|
+
case 'span':
|
|
2794
|
+
case 'div':
|
|
2795
|
+
return jsxRuntime.jsx(TagName, Object.assign({}, props, { children: children }));
|
|
2796
|
+
case 'br':
|
|
2797
|
+
return jsxRuntime.jsx("br", {});
|
|
2798
|
+
case 'a':
|
|
2799
|
+
props.href = element.getAttribute('href') || '';
|
|
2800
|
+
return jsxRuntime.jsx("a", Object.assign({}, props, { children: children }));
|
|
2801
|
+
case 'img':
|
|
2802
|
+
props.src = element.getAttribute('src') || '';
|
|
2803
|
+
props.alt = element.getAttribute('alt') || '';
|
|
2804
|
+
return jsxRuntime.jsx("img", Object.assign({}, props));
|
|
2805
|
+
case 'hr':
|
|
2806
|
+
return jsxRuntime.jsx("hr", {});
|
|
2807
|
+
default:
|
|
2808
|
+
return jsxRuntime.jsx("span", Object.assign({}, props, { children: children }));
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
return null;
|
|
2812
|
+
}
|
|
2813
|
+
return Array.from(tempDiv.childNodes).map(parseNode);
|
|
2814
|
+
}
|
|
2815
|
+
const commonState = useCommonState();
|
|
2816
|
+
const popupPosition = usePopupPosition();
|
|
2817
|
+
return scopedCss.withScopedCSS(scopedId$f, () => {
|
|
2818
|
+
const rect = popupPosition(400, 210);
|
|
2819
|
+
const b = commonState().inSourceCode || commonState().readonly && !selection.isCollapsed;
|
|
2820
|
+
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: {
|
|
2821
|
+
display: 'block'
|
|
2822
|
+
}, 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 &&
|
|
2823
|
+
jsxRuntime.jsx(Popup, { left: rect.left, top: rect.top, children: jsxRuntime.jsxs("div", { onClick: () => {
|
|
2824
|
+
isClickFromSelf = true;
|
|
2825
|
+
}, 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" })] })] }) })] }));
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
var scopedId$e = "vf-2a8a65";
|
|
2830
|
+
|
|
2831
|
+
exports.RefreshService = class RefreshService {
|
|
2832
|
+
constructor() {
|
|
2833
|
+
Object.defineProperty(this, "onRefresh", {
|
|
2834
|
+
enumerable: true,
|
|
2835
|
+
configurable: true,
|
|
2836
|
+
writable: true,
|
|
2837
|
+
value: new core$1.Subject()
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
};
|
|
2841
|
+
exports.RefreshService = __decorate([
|
|
2842
|
+
core.Injectable()
|
|
2843
|
+
], exports.RefreshService);
|
|
2844
|
+
|
|
2845
|
+
const textAlignAttr = new core$1.Attribute('textAlign', {
|
|
2846
|
+
render(node, formatValue) {
|
|
2847
|
+
node.styles.set('text-align', formatValue);
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
const textAlignAttrLoader = {
|
|
2851
|
+
match(element) {
|
|
2852
|
+
return !!element.style.textAlign;
|
|
2853
|
+
},
|
|
2854
|
+
read(element) {
|
|
2855
|
+
return {
|
|
2856
|
+
attribute: textAlignAttr,
|
|
2857
|
+
value: element.style.textAlign
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
};
|
|
2861
|
+
function registerTextAlignShortcut(textbus) {
|
|
2862
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
2863
|
+
const commander = textbus.get(core$1.Commander);
|
|
2864
|
+
keyboard.addShortcut({
|
|
2865
|
+
keymap: {
|
|
2866
|
+
key: 'lrej'.split(''),
|
|
2867
|
+
modKey: true
|
|
2868
|
+
},
|
|
2869
|
+
action(key) {
|
|
2870
|
+
const valueMap = {
|
|
2871
|
+
l: 'left',
|
|
2872
|
+
r: 'right',
|
|
2873
|
+
e: 'center',
|
|
2874
|
+
j: 'justify'
|
|
2875
|
+
};
|
|
2876
|
+
commander.applyAttribute(textAlignAttr, valueMap[key]);
|
|
2877
|
+
}
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2599
2881
|
function AttrTool(props) {
|
|
2600
2882
|
const commander = core.inject(core$1.Commander);
|
|
2601
2883
|
const selection = core.inject(core$1.Selection);
|
|
@@ -5023,44 +5305,9 @@ function ItalicTool() {
|
|
|
5023
5305
|
|
|
5024
5306
|
var scopedId$c = "vf-e74208";
|
|
5025
5307
|
|
|
5026
|
-
exports.EditorService = class EditorService {
|
|
5027
|
-
constructor() {
|
|
5028
|
-
Object.defineProperty(this, "hideInlineToolbar", {
|
|
5029
|
-
enumerable: true,
|
|
5030
|
-
configurable: true,
|
|
5031
|
-
writable: true,
|
|
5032
|
-
value: false
|
|
5033
|
-
});
|
|
5034
|
-
Object.defineProperty(this, "canShowLeftToolbar", {
|
|
5035
|
-
enumerable: true,
|
|
5036
|
-
configurable: true,
|
|
5037
|
-
writable: true,
|
|
5038
|
-
value: true
|
|
5039
|
-
});
|
|
5040
|
-
Object.defineProperty(this, "onLeftToolbarCanVisibleChange", {
|
|
5041
|
-
enumerable: true,
|
|
5042
|
-
configurable: true,
|
|
5043
|
-
writable: true,
|
|
5044
|
-
value: new core$1.Subject()
|
|
5045
|
-
});
|
|
5046
|
-
}
|
|
5047
|
-
changeLeftToolbarVisible(b) {
|
|
5048
|
-
this.canShowLeftToolbar = b;
|
|
5049
|
-
this.onLeftToolbarCanVisibleChange.next();
|
|
5050
|
-
}
|
|
5051
|
-
};
|
|
5052
|
-
exports.EditorService = __decorate([
|
|
5053
|
-
core.Injectable({
|
|
5054
|
-
provideIn: 'root'
|
|
5055
|
-
})
|
|
5056
|
-
], exports.EditorService);
|
|
5057
|
-
|
|
5058
5308
|
function LinkTool(props) {
|
|
5059
|
-
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
5060
|
-
const selection = core.inject(core$1.Selection);
|
|
5061
5309
|
const commander = core.inject(core$1.Commander);
|
|
5062
5310
|
const editorService = core.inject(exports.EditorService);
|
|
5063
|
-
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
5064
5311
|
const isShow = core.createSignal(false);
|
|
5065
5312
|
const value = core.createSignal('');
|
|
5066
5313
|
function setLink(ev) {
|
|
@@ -5084,19 +5331,16 @@ function LinkTool(props) {
|
|
|
5084
5331
|
sub.unsubscribe();
|
|
5085
5332
|
});
|
|
5086
5333
|
const commonState = useCommonState();
|
|
5334
|
+
const popupPosition = usePopupPosition();
|
|
5087
5335
|
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
5088
|
-
const
|
|
5089
|
-
const rect = isShow() ? selectionBridge.getRect({
|
|
5090
|
-
slot: selection.focusSlot,
|
|
5091
|
-
offset: selection.focusOffset
|
|
5092
|
-
}) : {};
|
|
5336
|
+
const rect = popupPosition(224, 38);
|
|
5093
5337
|
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, onClick: () => {
|
|
5094
5338
|
var _a;
|
|
5095
5339
|
isShow.set(true);
|
|
5096
5340
|
isClickFromSelf = true;
|
|
5097
5341
|
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
5098
5342
|
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
5099
|
-
jsxRuntime.jsx(Popup, { left: rect.left
|
|
5343
|
+
jsxRuntime.jsx(Popup, { left: rect.left, top: rect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
5100
5344
|
isClickFromSelf = true;
|
|
5101
5345
|
}, class: "input-group", children: [jsxRuntime.jsx("input", { onChange: ev => {
|
|
5102
5346
|
value.set(ev.target.value);
|
|
@@ -6149,6 +6393,7 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6149
6393
|
mousedownSubscription.unsubscribe();
|
|
6150
6394
|
mouseupSubscription.unsubscribe();
|
|
6151
6395
|
});
|
|
6396
|
+
const llmService = core.inject(LLMService, null);
|
|
6152
6397
|
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
6153
6398
|
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
|
|
6154
6399
|
left: viewPosition.left + 'px',
|
|
@@ -6157,7 +6402,7 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6157
6402
|
opacity: viewPosition.opacity,
|
|
6158
6403
|
display: editorService.hideInlineToolbar ? 'none' : '',
|
|
6159
6404
|
transitionDuration: viewPosition.transitionDuration + 's'
|
|
6160
|
-
}, 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")] }));
|
|
6405
|
+
}, 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")] }));
|
|
6161
6406
|
});
|
|
6162
6407
|
});
|
|
6163
6408
|
|
|
@@ -6214,8 +6459,9 @@ const StaticToolbar = core.withAnnotation({
|
|
|
6214
6459
|
core.onUnmounted(() => {
|
|
6215
6460
|
subscription.unsubscribe();
|
|
6216
6461
|
});
|
|
6462
|
+
const llmService = core.inject(LLMService, null);
|
|
6217
6463
|
return scopedCss.withScopedCSS(scopedId$7, () => {
|
|
6218
|
-
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")] }));
|
|
6464
|
+
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")] }));
|
|
6219
6465
|
});
|
|
6220
6466
|
});
|
|
6221
6467
|
|
|
@@ -6262,7 +6508,7 @@ class StaticToolbarPlugin {
|
|
|
6262
6508
|
}
|
|
6263
6509
|
}
|
|
6264
6510
|
|
|
6265
|
-
var scopedId$6 = "vf-
|
|
6511
|
+
var scopedId$6 = "vf-927bfc";
|
|
6266
6512
|
|
|
6267
6513
|
const SuspensionToolbar = core.withAnnotation({
|
|
6268
6514
|
providers: [exports.RefreshService, ToolService]
|
|
@@ -6297,14 +6543,15 @@ const SuspensionToolbar = core.withAnnotation({
|
|
|
6297
6543
|
}), core$1.delay(100)).subscribe(() => {
|
|
6298
6544
|
styles.opacity = 1;
|
|
6299
6545
|
}));
|
|
6546
|
+
const llmService = core.inject(LLMService, null);
|
|
6300
6547
|
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
6301
|
-
return (jsxRuntime.
|
|
6548
|
+
return (jsxRuntime.jsx("div", { class: ['toolbar', props.theme, {
|
|
6302
6549
|
suspension: styles.top === 0 ? '' : 'suspension'
|
|
6303
6550
|
}], style: {
|
|
6304
6551
|
top: styles.top + 'px',
|
|
6305
6552
|
opacity: styles.opacity,
|
|
6306
6553
|
pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
|
|
6307
|
-
}, 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")] }));
|
|
6554
|
+
}, 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")] }) }));
|
|
6308
6555
|
});
|
|
6309
6556
|
});
|
|
6310
6557
|
|
|
@@ -6332,6 +6579,7 @@ class SuspensionToolbarPlugin {
|
|
|
6332
6579
|
setup(injector) {
|
|
6333
6580
|
const host = injector.get(platformBrowser.VIEW_CONTAINER);
|
|
6334
6581
|
const container = document.createElement('div');
|
|
6582
|
+
container.style.cssText = 'display:flex;justify-content:center;';
|
|
6335
6583
|
this.app = platformBrowser$1.createApp(jsxRuntime.jsx(SuspensionToolbar, { theme: this.options.theme }), {
|
|
6336
6584
|
context: injector
|
|
6337
6585
|
});
|
|
@@ -8109,6 +8357,7 @@ class Editor extends core$1.Textbus {
|
|
|
8109
8357
|
}
|
|
8110
8358
|
}
|
|
8111
8359
|
|
|
8360
|
+
exports.AiTool = AiTool;
|
|
8112
8361
|
exports.AtComponent = AtComponent;
|
|
8113
8362
|
exports.AtComponentView = AtComponentView;
|
|
8114
8363
|
exports.AttrTool = AttrTool;
|
|
@@ -8144,6 +8393,7 @@ exports.ItalicTool = ItalicTool;
|
|
|
8144
8393
|
exports.KatexComponent = KatexComponent;
|
|
8145
8394
|
exports.KatexComponentView = KatexComponentView;
|
|
8146
8395
|
exports.Keymap = Keymap;
|
|
8396
|
+
exports.LLMService = LLMService;
|
|
8147
8397
|
exports.LeftToolbar = LeftToolbar;
|
|
8148
8398
|
exports.LeftToolbarPlugin = LeftToolbarPlugin;
|
|
8149
8399
|
exports.LinkJump = LinkJump;
|