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