@textbus/xnote 0.0.1-alpha.5 → 0.0.1-alpha.50
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/README.md +103 -1
- package/bundles/components/_api.d.ts +2 -0
- package/bundles/components/dropdown/dropdown-menu.d.ts +4 -1
- package/bundles/components/dropdown/dropdown.d.ts +3 -1
- package/bundles/components/keymap/keymap.d.ts +5 -0
- package/bundles/components/menu-heading/menu-heading.d.ts +2 -0
- package/bundles/components/menu-item/menu-item.d.ts +2 -1
- package/bundles/components/popup/popup.d.ts +1 -1
- package/bundles/editor.d.ts +13 -6
- package/bundles/fonts/textbus.svg +3 -32
- 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 +1972 -1109
- package/bundles/index.js +1984 -1105
- package/bundles/interfaces.d.ts +3 -0
- package/bundles/plugins/_api.d.ts +1 -0
- package/bundles/plugins/_common/attr.tool.d.ts +2 -2
- package/bundles/plugins/_common/color.tool.d.ts +2 -2
- package/bundles/plugins/left-toolbar/insert-tool.d.ts +1 -0
- package/bundles/plugins/link-jump/link-jump.d.ts +4 -0
- package/bundles/public-api.d.ts +1 -0
- package/bundles/services/editor.service.d.ts +4 -0
- package/bundles/textbus/components/SlotRender.d.ts +14 -0
- package/bundles/textbus/components/_api.d.ts +3 -0
- package/bundles/textbus/components/at/at-component.view.d.ts +6 -0
- package/bundles/textbus/components/at/at.component.d.ts +35 -0
- package/bundles/textbus/components/blockqoute/blockquote.component.d.ts +4 -1
- package/bundles/textbus/components/highlight-box/highlight-box.component.d.ts +1 -0
- package/bundles/textbus/components/image/image.component.d.ts +2 -1
- package/bundles/textbus/components/katex/katex-editor.d.ts +7 -0
- package/bundles/textbus/components/katex/katex.component.d.ts +16 -0
- package/bundles/textbus/components/list/list.component.d.ts +3 -0
- package/bundles/textbus/components/paragraph/paragraph.component.d.ts +1 -0
- package/bundles/textbus/components/root/root.component.d.ts +1 -1
- package/bundles/textbus/components/source-code/source-code.component.d.ts +2 -1
- package/bundles/textbus/components/table/components/resize-column.d.ts +2 -1
- package/bundles/textbus/components/table/components/scroll.d.ts +1 -2
- package/bundles/textbus/components/table/components/top-bar.d.ts +2 -2
- package/bundles/textbus/components/table/table-selection-awareness-delegate.d.ts +15 -0
- package/bundles/textbus/components/table/table.component.d.ts +1 -1
- package/bundles/textbus/components/todolist/todolist.component.d.ts +1 -0
- package/bundles/textbus/components/video/video.component.d.ts +1 -1
- package/package.json +36 -12
package/bundles/index.js
CHANGED
|
@@ -8,10 +8,12 @@ var platformBrowser = require('@textbus/platform-browser');
|
|
|
8
8
|
var platformBrowser$1 = require('@viewfly/platform-browser');
|
|
9
9
|
var hooks = require('@viewfly/hooks');
|
|
10
10
|
var highlightjs = require('highlight.js');
|
|
11
|
+
var Katex = require('katex');
|
|
11
12
|
var adapterViewfly = require('@textbus/adapter-viewfly');
|
|
13
|
+
var color = require('@tanbo/color');
|
|
12
14
|
var collaborate = require('@textbus/collaborate');
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var scopedId$n = "vf-d94b56";
|
|
15
17
|
|
|
16
18
|
/******************************************************************************
|
|
17
19
|
Copyright (c) Microsoft Corporation.
|
|
@@ -30,6 +32,18 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
30
32
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
31
33
|
|
|
32
34
|
|
|
35
|
+
function __rest(s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
|
|
33
47
|
function __decorate(decorators, target, key, desc) {
|
|
34
48
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35
49
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -41,16 +55,6 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
41
55
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
42
56
|
}
|
|
43
57
|
|
|
44
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
45
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
49
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
58
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
59
|
var e = new Error(message);
|
|
56
60
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -83,7 +87,7 @@ exports.DropdownContextService = DropdownContextService_1 = class DropdownContex
|
|
|
83
87
|
this.canHide = true;
|
|
84
88
|
this.openStateChangeEvent = new core$1.Subject();
|
|
85
89
|
this.timer = null;
|
|
86
|
-
this.parentDropdownContextService = this.injector.get(DropdownContextService_1, core.InjectFlags.SkipSelf
|
|
90
|
+
this.parentDropdownContextService = this.injector.get(DropdownContextService_1, null, core.InjectFlags.SkipSelf);
|
|
87
91
|
this.onOpenStateChange = this.openStateChangeEvent.asObservable();
|
|
88
92
|
dropdownService.onSiblingOpen.subscribe(id => {
|
|
89
93
|
if (id === this.id) {
|
|
@@ -132,7 +136,7 @@ exports.DropdownContextService = DropdownContextService_1 = __decorate([
|
|
|
132
136
|
], exports.DropdownContextService);
|
|
133
137
|
|
|
134
138
|
function Button(props) {
|
|
135
|
-
const dropdownContextService = core.inject(exports.DropdownContextService,
|
|
139
|
+
const dropdownContextService = core.inject(exports.DropdownContextService, null);
|
|
136
140
|
const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
|
|
137
141
|
if (dropdownContextService) {
|
|
138
142
|
const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
|
|
@@ -142,7 +146,7 @@ function Button(props) {
|
|
|
142
146
|
subscription.unsubscribe();
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
|
-
return scopedCss.withScopedCSS(
|
|
149
|
+
return scopedCss.withScopedCSS(scopedId$n, () => {
|
|
146
150
|
return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
147
151
|
'btn',
|
|
148
152
|
{
|
|
@@ -154,10 +158,10 @@ function Button(props) {
|
|
|
154
158
|
});
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
var
|
|
161
|
+
var scopedId$m = "vf-ac7e8d";
|
|
158
162
|
|
|
159
163
|
function ComponentToolbar(props) {
|
|
160
|
-
return scopedCss.withScopedCSS(
|
|
164
|
+
return scopedCss.withScopedCSS(scopedId$m, () => {
|
|
161
165
|
return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
|
|
162
166
|
'toolbar',
|
|
163
167
|
{
|
|
@@ -167,15 +171,15 @@ function ComponentToolbar(props) {
|
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
var
|
|
174
|
+
var scopedId$l = "vf-ede279";
|
|
171
175
|
|
|
172
176
|
function Divider() {
|
|
173
|
-
return scopedCss.withScopedCSS(
|
|
177
|
+
return scopedCss.withScopedCSS(scopedId$l, () => {
|
|
174
178
|
return jsxRuntime.jsx("div", { class: "divider" });
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
var
|
|
182
|
+
var scopedId$k = "vf-8abf2c";
|
|
179
183
|
|
|
180
184
|
function DragResize(props) {
|
|
181
185
|
const isShow = core.createSignal(false);
|
|
@@ -196,7 +200,7 @@ function DragResize(props) {
|
|
|
196
200
|
isShow.set(true);
|
|
197
201
|
const width = ref.current.offsetWidth;
|
|
198
202
|
const height = ref.current.offsetHeight;
|
|
199
|
-
|
|
203
|
+
sizeText.set(`${Math.round(width)}px * ${Math.round(height)}px`);
|
|
200
204
|
});
|
|
201
205
|
function selectComponent() {
|
|
202
206
|
selection.selectComponent(component, true);
|
|
@@ -273,7 +277,7 @@ function DragResize(props) {
|
|
|
273
277
|
}
|
|
274
278
|
ele.style.width = endWidth + 'px';
|
|
275
279
|
ele.style.height = endHeight + 'px';
|
|
276
|
-
|
|
280
|
+
sizeText.set(`${Math.round(endWidth)}px * ${Math.round(endHeight)}px`);
|
|
277
281
|
});
|
|
278
282
|
const unUp = core$1.fromEvent(document, 'mouseup').subscribe(() => {
|
|
279
283
|
component.state.width = endWidth + 'px';
|
|
@@ -283,16 +287,17 @@ function DragResize(props) {
|
|
|
283
287
|
unUp.unsubscribe();
|
|
284
288
|
});
|
|
285
289
|
}
|
|
286
|
-
|
|
290
|
+
const sizeText = core.createSignal(`${component.state.width}*${component.state.height}`);
|
|
291
|
+
return scopedCss.withScopedCSS(scopedId$k, () => {
|
|
287
292
|
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', {
|
|
288
293
|
active: isShow()
|
|
289
|
-
}], children: [jsxRuntime.
|
|
294
|
+
}], 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" })] })] })] }));
|
|
290
295
|
});
|
|
291
296
|
}
|
|
292
297
|
|
|
293
|
-
var
|
|
298
|
+
var scopedId$j = "vf-a99c5e";
|
|
294
299
|
|
|
295
|
-
var
|
|
300
|
+
var scopedId$i = "vf-8a05e9";
|
|
296
301
|
|
|
297
302
|
const DropdownMenuPortal = core.withAnnotation({
|
|
298
303
|
providers: [
|
|
@@ -300,11 +305,14 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
300
305
|
]
|
|
301
306
|
}, function DropdownMenuPortal(props) {
|
|
302
307
|
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
308
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
303
309
|
const menuRef = core.createRef();
|
|
304
310
|
let timer = null;
|
|
305
311
|
const delay = 10;
|
|
306
|
-
|
|
312
|
+
function update() {
|
|
307
313
|
const menuElement = menuRef.current;
|
|
314
|
+
menuElement.style.height = 'auto';
|
|
315
|
+
const containerRect = container.getBoundingClientRect();
|
|
308
316
|
if (props.abreast) {
|
|
309
317
|
const btnEle = props.triggerRef.current;
|
|
310
318
|
const screenHeight = document.documentElement.clientHeight;
|
|
@@ -319,19 +327,19 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
319
327
|
else if (offsetTop + maxHeight > screenHeight - 10) {
|
|
320
328
|
offsetTop = screenHeight - 10 - maxHeight;
|
|
321
329
|
}
|
|
322
|
-
menuElement.style.top = offsetTop + 'px';
|
|
330
|
+
menuElement.style.top = offsetTop - containerRect.top + 'px';
|
|
323
331
|
const triggerRect = props.triggerRef.current.getBoundingClientRect();
|
|
324
332
|
const leftDistance = triggerRect.left;
|
|
325
333
|
const isToLeft = leftDistance >= menuElement.offsetWidth + 20;
|
|
326
|
-
if (isToLeft) {
|
|
327
|
-
menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 + 'px';
|
|
334
|
+
if (isToLeft && props.toLeft) {
|
|
335
|
+
menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 - containerRect.left + 'px';
|
|
328
336
|
timer = setTimeout(() => {
|
|
329
337
|
menuElement.style.transform = 'translateX(10px)';
|
|
330
338
|
menuElement.style.opacity = '1';
|
|
331
339
|
}, delay);
|
|
332
340
|
}
|
|
333
341
|
else {
|
|
334
|
-
menuElement.style.left = triggerRect.right + 20 + 'px';
|
|
342
|
+
menuElement.style.left = triggerRect.right + 20 - containerRect.left + 'px';
|
|
335
343
|
timer = setTimeout(() => {
|
|
336
344
|
menuElement.style.transform = 'translateX(-10px)';
|
|
337
345
|
menuElement.style.opacity = '1';
|
|
@@ -343,12 +351,12 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
343
351
|
const documentClientHeight = document.documentElement.clientHeight;
|
|
344
352
|
const bottomDistance = documentClientHeight - triggerRect.bottom;
|
|
345
353
|
const isToTop = bottomDistance < 200 && triggerRect.top > bottomDistance;
|
|
346
|
-
menuElement.style.left = triggerRect.left + 'px';
|
|
354
|
+
menuElement.style.left = triggerRect.left - containerRect.left + 'px';
|
|
347
355
|
if (isToTop) {
|
|
348
356
|
const maxHeight = Math.max(menuElement.scrollHeight, menuElement.offsetHeight);
|
|
349
|
-
const height = Math.min(triggerRect.top - 20, maxHeight);
|
|
357
|
+
const height = Math.min(triggerRect.top - 20, maxHeight, 400);
|
|
350
358
|
menuElement.style.height = height + 'px';
|
|
351
|
-
menuElement.style.top = triggerRect.top - 20 - height + 'px';
|
|
359
|
+
menuElement.style.top = triggerRect.top - 20 - height - containerRect.top + 'px';
|
|
352
360
|
timer = setTimeout(() => {
|
|
353
361
|
menuElement.style.transform = 'translateY(10px)';
|
|
354
362
|
menuElement.style.opacity = '1';
|
|
@@ -356,30 +364,41 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
356
364
|
}
|
|
357
365
|
else {
|
|
358
366
|
menuElement.style.height = Math.min(bottomDistance - 20, menuElement.scrollHeight) + 'px';
|
|
359
|
-
menuElement.style.top = triggerRect.bottom + 20 + 'px';
|
|
367
|
+
menuElement.style.top = triggerRect.bottom + 20 - containerRect.top + 'px';
|
|
360
368
|
timer = setTimeout(() => {
|
|
361
369
|
menuElement.style.transform = 'translateY(-10px)';
|
|
362
370
|
menuElement.style.opacity = '1';
|
|
363
371
|
}, delay);
|
|
364
372
|
}
|
|
365
373
|
}
|
|
374
|
+
}
|
|
375
|
+
core.onUpdated(() => {
|
|
376
|
+
update();
|
|
366
377
|
});
|
|
367
378
|
core.onUnmounted(() => {
|
|
368
379
|
clearTimeout(timer);
|
|
369
380
|
});
|
|
370
381
|
function onEnter() {
|
|
382
|
+
if (props.noTrigger) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
371
385
|
dropdownContextService.canHide = false;
|
|
372
386
|
dropdownContextService.open();
|
|
373
387
|
}
|
|
374
388
|
function onLeave() {
|
|
389
|
+
if (props.noTrigger) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
375
392
|
dropdownContextService.canHide = true;
|
|
376
393
|
dropdownContextService.hide();
|
|
377
394
|
}
|
|
378
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
395
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$i, () => {
|
|
379
396
|
return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
|
|
380
397
|
width: props.width
|
|
381
|
-
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content",
|
|
382
|
-
|
|
398
|
+
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
|
|
399
|
+
padding: props.padding
|
|
400
|
+
}, children: props.children }) }));
|
|
401
|
+
}), container);
|
|
383
402
|
});
|
|
384
403
|
|
|
385
404
|
const Dropdown = core.withAnnotation({
|
|
@@ -407,6 +426,9 @@ const Dropdown = core.withAnnotation({
|
|
|
407
426
|
});
|
|
408
427
|
const subscription = new core$1.Subscription();
|
|
409
428
|
core.onMounted(() => {
|
|
429
|
+
if (props.trigger === 'none') {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
410
432
|
if (props.trigger === 'click') {
|
|
411
433
|
subscription.add(core$1.fromEvent(triggerRef.current, 'click').subscribe(toggle));
|
|
412
434
|
return;
|
|
@@ -432,14 +454,14 @@ const Dropdown = core.withAnnotation({
|
|
|
432
454
|
return {
|
|
433
455
|
isShow(b) {
|
|
434
456
|
if (b) {
|
|
435
|
-
dropdownContextService.
|
|
457
|
+
dropdownContextService.open();
|
|
436
458
|
}
|
|
437
459
|
else {
|
|
438
|
-
dropdownContextService.
|
|
460
|
+
dropdownContextService.hide(false);
|
|
439
461
|
}
|
|
440
462
|
},
|
|
441
|
-
$render: scopedCss.withScopedCSS(
|
|
442
|
-
return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsxRuntime.jsx(DropdownMenuPortal, { width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
463
|
+
$render: scopedCss.withScopedCSS(scopedId$j, () => {
|
|
464
|
+
return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsxRuntime.jsx(DropdownMenuPortal, { toLeft: props.toLeft, padding: props.padding, noTrigger: props.trigger === 'none', width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
443
465
|
props.menu.map(menu => {
|
|
444
466
|
return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
|
|
445
467
|
var _a;
|
|
@@ -454,10 +476,54 @@ const Dropdown = core.withAnnotation({
|
|
|
454
476
|
};
|
|
455
477
|
});
|
|
456
478
|
|
|
457
|
-
var
|
|
479
|
+
var scopedId$h = "vf-c32a7b";
|
|
480
|
+
|
|
481
|
+
function Keymap(props) {
|
|
482
|
+
const arr = [];
|
|
483
|
+
const keymap = props.keymap;
|
|
484
|
+
if (keymap.ctrlKey) {
|
|
485
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-command" }) : jsxRuntime.jsx("span", { children: "Ctrl" }));
|
|
486
|
+
}
|
|
487
|
+
if (keymap.shiftKey) {
|
|
488
|
+
if (arr.length) {
|
|
489
|
+
arr.push('+');
|
|
490
|
+
}
|
|
491
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-shift" }) : jsxRuntime.jsx("span", { children: "Shift" }));
|
|
492
|
+
}
|
|
493
|
+
if (keymap.altKey) {
|
|
494
|
+
if (arr.length) {
|
|
495
|
+
arr.push('+');
|
|
496
|
+
}
|
|
497
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-opt" }) : jsxRuntime.jsx("span", { children: "Alt" }));
|
|
498
|
+
}
|
|
499
|
+
if (keymap.key) {
|
|
500
|
+
if (arr.length) {
|
|
501
|
+
arr.push('+');
|
|
502
|
+
}
|
|
503
|
+
if (Array.isArray(keymap.key)) {
|
|
504
|
+
arr.push(jsxRuntime.jsx("span", { children: keymap.key.join('/') }));
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return scopedCss.withScopedCSS(scopedId$h, () => {
|
|
511
|
+
return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
var scopedId$g = "vf-acaa5f";
|
|
516
|
+
|
|
517
|
+
function MenuHeading(props) {
|
|
518
|
+
return scopedCss.withScopedCSS(scopedId$g, () => {
|
|
519
|
+
return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var scopedId$f = "vf-c3b9dc";
|
|
458
524
|
|
|
459
525
|
function MenuItem(props) {
|
|
460
|
-
const dropdownContextService = core.inject(exports.DropdownContextService,
|
|
526
|
+
const dropdownContextService = core.inject(exports.DropdownContextService, null);
|
|
461
527
|
const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
|
|
462
528
|
if (dropdownContextService) {
|
|
463
529
|
const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
|
|
@@ -474,8 +540,8 @@ function MenuItem(props) {
|
|
|
474
540
|
}
|
|
475
541
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
|
|
476
542
|
}
|
|
477
|
-
return scopedCss.withScopedCSS(
|
|
478
|
-
return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), props.arrow ?
|
|
543
|
+
return scopedCss.withScopedCSS(scopedId$f, () => {
|
|
544
|
+
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 ?
|
|
479
545
|
jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
|
|
480
546
|
jsxRuntime.jsx("div", { class: [
|
|
481
547
|
'menu-check',
|
|
@@ -484,11 +550,11 @@ function MenuItem(props) {
|
|
|
484
550
|
});
|
|
485
551
|
}
|
|
486
552
|
|
|
487
|
-
var
|
|
553
|
+
var scopedId$e = "vf-a23c47";
|
|
488
554
|
|
|
489
555
|
function Popup(props) {
|
|
490
556
|
const host = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
491
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
557
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$e, () => {
|
|
492
558
|
return (jsxRuntime.jsx("div", { class: "popup", style: {
|
|
493
559
|
left: props.left + 'px',
|
|
494
560
|
top: props.top + 'px'
|
|
@@ -496,15 +562,15 @@ function Popup(props) {
|
|
|
496
562
|
}), host);
|
|
497
563
|
}
|
|
498
564
|
|
|
499
|
-
var
|
|
565
|
+
var scopedId$d = "vf-216815";
|
|
500
566
|
|
|
501
567
|
function ToolbarItem(props) {
|
|
502
|
-
return scopedCss.withScopedCSS(
|
|
568
|
+
return scopedCss.withScopedCSS(scopedId$d, () => {
|
|
503
569
|
return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
|
|
504
570
|
});
|
|
505
571
|
}
|
|
506
572
|
|
|
507
|
-
var
|
|
573
|
+
var scopedId$c = "vf-2a8a65";
|
|
508
574
|
|
|
509
575
|
exports.RefreshService = class RefreshService {
|
|
510
576
|
constructor() {
|
|
@@ -560,108 +626,432 @@ function useReadonly() {
|
|
|
560
626
|
return is;
|
|
561
627
|
}
|
|
562
628
|
|
|
563
|
-
|
|
629
|
+
const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
|
|
630
|
+
|
|
631
|
+
function useOutput() {
|
|
632
|
+
return core.createSignal(core.inject(OutputInjectionToken));
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
const headingAttr = new core$1.Attribute('Heading', {
|
|
636
|
+
render(node, formatValue) {
|
|
637
|
+
node.classes.add('xnote-' + formatValue);
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
const headingAttrLoader = {
|
|
641
|
+
match(element) {
|
|
642
|
+
return /H[1-6]/.test(element.tagName) || /(^|\s)xnote-h[1-6](\s|$)/.test(element.className);
|
|
643
|
+
},
|
|
644
|
+
read(element) {
|
|
645
|
+
if (/H[1-6]/.test(element.tagName)) {
|
|
646
|
+
return {
|
|
647
|
+
attribute: headingAttr,
|
|
648
|
+
value: element.tagName.toLowerCase()
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
attribute: headingAttr,
|
|
653
|
+
value: element.className.substring(6)
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
function registerHeadingShortcut(textbus) {
|
|
658
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
659
|
+
const commander = textbus.get(core$1.Commander);
|
|
660
|
+
const selection = textbus.get(core$1.Selection);
|
|
661
|
+
keyboard.addShortcut({
|
|
662
|
+
keymap: {
|
|
663
|
+
key: '0123456'.split(''),
|
|
664
|
+
ctrlKey: true
|
|
665
|
+
},
|
|
666
|
+
action(key) {
|
|
667
|
+
if (key === '0') {
|
|
668
|
+
commander.unApplyAttribute(headingAttr);
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
commander.applyAttribute(headingAttr, 'h' + key);
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
keyboard.addZenCodingInterceptor({
|
|
675
|
+
match(content) {
|
|
676
|
+
return /^#{1,6}$/.test(content);
|
|
677
|
+
},
|
|
678
|
+
try(key) {
|
|
679
|
+
return key === ' ';
|
|
680
|
+
},
|
|
681
|
+
action(content) {
|
|
682
|
+
if (selection.commonAncestorComponent instanceof SourceCodeComponent) {
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
686
|
+
commonAncestorSlot.cut();
|
|
687
|
+
commander.applyAttribute(headingAttr, 'h' + content.length);
|
|
688
|
+
selection.setPosition(commonAncestorSlot, 0);
|
|
689
|
+
return true;
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function useBlockContent(slot) {
|
|
695
|
+
const textbus = core$1.useContext();
|
|
696
|
+
const selection = textbus.get(core$1.Selection);
|
|
697
|
+
core$1.onBreak(ev => {
|
|
698
|
+
if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
|
|
699
|
+
const p = new ParagraphComponent(textbus);
|
|
700
|
+
ev.target.insert(p);
|
|
701
|
+
selection.setPosition(p.state.slot, 0);
|
|
702
|
+
ev.preventDefault();
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
core$1.onContentInsert(ev => {
|
|
706
|
+
if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
|
|
707
|
+
(typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
|
|
708
|
+
const p = new ParagraphComponent(textbus);
|
|
709
|
+
const childSlot = p.state.slot;
|
|
710
|
+
childSlot.insert(ev.data.content);
|
|
711
|
+
ev.target.insert(p);
|
|
712
|
+
selection.setPosition(childSlot, childSlot.index);
|
|
713
|
+
ev.preventDefault();
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function SlotRender(props) {
|
|
719
|
+
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
720
|
+
const instance = core.getCurrentInstance();
|
|
721
|
+
const slot = props.slot;
|
|
722
|
+
const sub = core$1.merge(slot.__changeMarker__.onChange, slot.__changeMarker__.onForceChange).subscribe(() => {
|
|
723
|
+
if (props.slot.__changeMarker__.dirty) {
|
|
724
|
+
instance.markAsDirtied();
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
core.onUnmounted(() => {
|
|
728
|
+
sub.unsubscribe();
|
|
729
|
+
});
|
|
730
|
+
return () => {
|
|
731
|
+
const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
|
|
732
|
+
return adapter.slotRender(slot, children => {
|
|
733
|
+
return core$1.createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
|
|
734
|
+
}, renderEnv);
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
class BlockquoteComponent extends core$1.Component {
|
|
564
739
|
static fromJSON(textbus, json) {
|
|
565
740
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
566
|
-
return new
|
|
741
|
+
return new BlockquoteComponent(textbus, {
|
|
567
742
|
slot
|
|
568
743
|
});
|
|
569
744
|
}
|
|
570
745
|
constructor(textbus, state = {
|
|
571
746
|
slot: new core$1.Slot([
|
|
572
|
-
core$1.ContentType.
|
|
573
|
-
core$1.ContentType.Text
|
|
747
|
+
core$1.ContentType.BlockComponent
|
|
574
748
|
])
|
|
575
749
|
}) {
|
|
576
750
|
super(textbus, state);
|
|
577
751
|
}
|
|
752
|
+
getSlots() {
|
|
753
|
+
return [this.state.slot];
|
|
754
|
+
}
|
|
578
755
|
setup() {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
756
|
+
useBlockContent(this.state.slot);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
BlockquoteComponent.type = core$1.ContentType.BlockComponent;
|
|
760
|
+
BlockquoteComponent.componentName = 'BlockquoteComponent';
|
|
761
|
+
BlockquoteComponent.zenCoding = {
|
|
762
|
+
key: ' ',
|
|
763
|
+
match(content, textbus) {
|
|
764
|
+
const selection = textbus.get(core$1.Selection);
|
|
765
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
766
|
+
return /^>$/.test(content);
|
|
767
|
+
}
|
|
768
|
+
return false;
|
|
769
|
+
},
|
|
770
|
+
createState(_, textbus) {
|
|
771
|
+
const selection = textbus.get(core$1.Selection);
|
|
772
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
773
|
+
const slot = new core$1.Slot([
|
|
774
|
+
core$1.ContentType.BlockComponent
|
|
775
|
+
]);
|
|
776
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
777
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
778
|
+
}
|
|
779
|
+
return {
|
|
780
|
+
slot
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
function toBlockquote(textbus) {
|
|
785
|
+
const query = textbus.get(core$1.Query);
|
|
786
|
+
const commander = textbus.get(core$1.Commander);
|
|
787
|
+
const selection = textbus.get(core$1.Selection);
|
|
788
|
+
const state = query.queryComponent(BlockquoteComponent);
|
|
789
|
+
if (state.state === core$1.QueryStateType.Enabled) {
|
|
790
|
+
const current = state.value;
|
|
791
|
+
const parent = current.parent;
|
|
792
|
+
const index = parent.indexOf(current);
|
|
793
|
+
parent.retain(index);
|
|
794
|
+
commander.removeComponent(current);
|
|
795
|
+
current.slots.at(0).sliceContent().forEach(i => {
|
|
796
|
+
parent.insert(i);
|
|
590
797
|
});
|
|
591
798
|
}
|
|
799
|
+
else {
|
|
800
|
+
const block = new BlockquoteComponent(textbus);
|
|
801
|
+
const slot = block.state.slot;
|
|
802
|
+
if (selection.startSlot === selection.endSlot) {
|
|
803
|
+
const parentComponent = selection.startSlot.parent;
|
|
804
|
+
const parentSlot = parentComponent.parent;
|
|
805
|
+
const position = parentSlot.indexOf(parentComponent);
|
|
806
|
+
slot.insert(parentComponent);
|
|
807
|
+
parentSlot.retain(position);
|
|
808
|
+
parentSlot.insert(block);
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
812
|
+
const scope = selection.getCommonAncestorSlotScope();
|
|
813
|
+
commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
|
|
814
|
+
slot.insert(i);
|
|
815
|
+
});
|
|
816
|
+
commonAncestorSlot.retain(scope.startOffset);
|
|
817
|
+
commonAncestorSlot.insert(block);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
592
820
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
821
|
+
function registerBlockquoteShortcut(textbus) {
|
|
822
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
823
|
+
keyboard.addShortcut({
|
|
824
|
+
keymap: {
|
|
825
|
+
ctrlKey: true,
|
|
826
|
+
key: '\''
|
|
827
|
+
},
|
|
828
|
+
action() {
|
|
829
|
+
toBlockquote(textbus);
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
function BlockquoteView(props) {
|
|
597
834
|
const readonly = useReadonly();
|
|
835
|
+
const output = useOutput();
|
|
598
836
|
return () => {
|
|
599
837
|
const slot = props.component.state.slot;
|
|
600
|
-
return (jsxRuntime.jsx("
|
|
601
|
-
return (core$1.createVNode('p', null, children));
|
|
602
|
-
}, readonly()) }));
|
|
838
|
+
return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
|
|
603
839
|
};
|
|
604
840
|
}
|
|
605
|
-
const
|
|
606
|
-
match(element) {
|
|
607
|
-
return
|
|
841
|
+
const blockquoteComponentLoader = {
|
|
842
|
+
match(element, returnableContentTypes) {
|
|
843
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
|
|
608
844
|
},
|
|
609
845
|
read(element, textbus, slotParser) {
|
|
610
846
|
const delta = slotParser(new core$1.Slot([
|
|
611
|
-
core$1.ContentType.
|
|
847
|
+
core$1.ContentType.BlockComponent,
|
|
612
848
|
core$1.ContentType.InlineComponent,
|
|
613
|
-
core$1.ContentType.
|
|
614
|
-
]),
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
return results[0];
|
|
618
|
-
}
|
|
619
|
-
const containerSlot = new core$1.Slot([
|
|
620
|
-
core$1.ContentType.BlockComponent
|
|
849
|
+
core$1.ContentType.Text
|
|
850
|
+
]), element).toDelta();
|
|
851
|
+
const slot = new core$1.Slot([
|
|
852
|
+
core$1.ContentType.BlockComponent,
|
|
621
853
|
]);
|
|
622
|
-
|
|
623
|
-
|
|
854
|
+
deltaToBlock(delta, textbus).forEach(i => {
|
|
855
|
+
slot.insert(i);
|
|
624
856
|
});
|
|
625
|
-
return
|
|
626
|
-
|
|
857
|
+
return new BlockquoteComponent(textbus, {
|
|
858
|
+
slot
|
|
859
|
+
});
|
|
860
|
+
},
|
|
627
861
|
};
|
|
628
|
-
function deltaToBlock(delta, textbus) {
|
|
629
|
-
const results = [];
|
|
630
|
-
let slot = null;
|
|
631
|
-
for (const item of delta) {
|
|
632
|
-
if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
|
|
633
|
-
if (!slot) {
|
|
634
|
-
slot = new core$1.Slot([
|
|
635
|
-
core$1.ContentType.InlineComponent,
|
|
636
|
-
core$1.ContentType.Text
|
|
637
|
-
]);
|
|
638
|
-
delta.attributes.forEach((value, key) => {
|
|
639
|
-
slot.setAttribute(key, value);
|
|
640
|
-
});
|
|
641
|
-
results.push(new ParagraphComponent(textbus, {
|
|
642
|
-
slot
|
|
643
|
-
}));
|
|
644
|
-
}
|
|
645
|
-
slot.insert(item.insert, item.formats);
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
results.push(item.insert);
|
|
649
|
-
slot = null;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return results;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
|
|
656
862
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
863
|
+
class HighlightBoxComponent extends core$1.Component {
|
|
864
|
+
static fromJSON(textbus, json) {
|
|
865
|
+
return new HighlightBoxComponent(textbus, {
|
|
866
|
+
type: json.type,
|
|
867
|
+
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
constructor(textbus, state = {
|
|
871
|
+
type: '',
|
|
872
|
+
slot: new core$1.Slot([
|
|
873
|
+
core$1.ContentType.BlockComponent,
|
|
874
|
+
])
|
|
875
|
+
}) {
|
|
876
|
+
super(textbus, state);
|
|
877
|
+
}
|
|
878
|
+
getSlots() {
|
|
879
|
+
return [this.state.slot];
|
|
880
|
+
}
|
|
881
|
+
setup() {
|
|
882
|
+
useBlockContent(this.state.slot);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
|
|
886
|
+
HighlightBoxComponent.componentName = 'HighlightBoxComponent';
|
|
887
|
+
HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
|
|
888
|
+
function HighlightBoxView(props) {
|
|
889
|
+
const readonly = useReadonly();
|
|
890
|
+
const output = useOutput();
|
|
891
|
+
const emoji = [];
|
|
892
|
+
for (let i = 0x1F600; i <= 0x1F64F; i++) {
|
|
893
|
+
emoji.push(i);
|
|
894
|
+
}
|
|
895
|
+
const dropdownRef = core.createRef();
|
|
896
|
+
function setType(type) {
|
|
897
|
+
var _a;
|
|
898
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
899
|
+
props.component.state.type = type;
|
|
900
|
+
}
|
|
901
|
+
return () => {
|
|
902
|
+
const { state, name } = props.component;
|
|
903
|
+
if (readonly() || output()) {
|
|
904
|
+
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
|
|
905
|
+
}
|
|
906
|
+
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "282px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u5E38\u7528" }), HighlightBoxComponent.defaultTypes.map(icon => {
|
|
907
|
+
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
908
|
+
}), jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
|
|
909
|
+
const icon = String.fromCodePoint(i);
|
|
910
|
+
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
911
|
+
})] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
const highlightBoxComponentLoader = {
|
|
915
|
+
match(element) {
|
|
916
|
+
return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
|
|
917
|
+
},
|
|
918
|
+
read(element, textbus, slotParser) {
|
|
919
|
+
const delta = slotParser(new core$1.Slot([
|
|
920
|
+
core$1.ContentType.BlockComponent,
|
|
921
|
+
core$1.ContentType.InlineComponent,
|
|
922
|
+
core$1.ContentType.Text
|
|
923
|
+
]), element.querySelector('.xnote-highlight-box-content')).toDelta();
|
|
924
|
+
const slot = new core$1.Slot([
|
|
925
|
+
core$1.ContentType.BlockComponent,
|
|
926
|
+
]);
|
|
927
|
+
deltaToBlock(delta, textbus).forEach(i => {
|
|
928
|
+
slot.insert(i);
|
|
929
|
+
});
|
|
930
|
+
return new HighlightBoxComponent(textbus, {
|
|
931
|
+
type: element.dataset.icon || '',
|
|
932
|
+
slot
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
class ParagraphComponent extends core$1.Component {
|
|
938
|
+
static fromJSON(textbus, json) {
|
|
939
|
+
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
940
|
+
return new ParagraphComponent(textbus, {
|
|
941
|
+
slot
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
constructor(textbus, state = {
|
|
945
|
+
slot: new core$1.Slot([
|
|
946
|
+
core$1.ContentType.InlineComponent,
|
|
947
|
+
core$1.ContentType.Text
|
|
948
|
+
])
|
|
949
|
+
}) {
|
|
950
|
+
super(textbus, state);
|
|
951
|
+
}
|
|
952
|
+
getSlots() {
|
|
953
|
+
return [this.state.slot];
|
|
954
|
+
}
|
|
955
|
+
setup() {
|
|
956
|
+
const injector = core$1.useContext();
|
|
957
|
+
const commander = injector.get(core$1.Commander);
|
|
958
|
+
const selection = injector.get(core$1.Selection);
|
|
959
|
+
core$1.onBreak(ev => {
|
|
960
|
+
const isEmpty = this.state.slot.isEmpty;
|
|
961
|
+
const afterSlot = ev.target.cut(ev.data.index);
|
|
962
|
+
afterSlot.removeAttribute(headingAttr);
|
|
963
|
+
const nextParagraph = new ParagraphComponent(injector, {
|
|
964
|
+
slot: afterSlot
|
|
965
|
+
});
|
|
966
|
+
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
967
|
+
this.parentComponent instanceof HighlightBoxComponent)) {
|
|
968
|
+
commander.insertAfter(nextParagraph, this.parentComponent);
|
|
969
|
+
commander.removeComponent(this);
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
commander.insertAfter(nextParagraph, this);
|
|
973
|
+
}
|
|
974
|
+
selection.setPosition(afterSlot, 0);
|
|
975
|
+
ev.preventDefault();
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
ParagraphComponent.componentName = 'ParagraphComponent';
|
|
980
|
+
ParagraphComponent.type = core$1.ContentType.BlockComponent;
|
|
981
|
+
function ParagraphView(props) {
|
|
982
|
+
const readonly = useReadonly();
|
|
983
|
+
const output = useOutput();
|
|
984
|
+
return () => {
|
|
985
|
+
const slot = props.component.state.slot;
|
|
986
|
+
return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.componentName, children: jsxRuntime.jsx(SlotRender, { tag: "div", slot: slot, renderEnv: readonly() || output() }) }));
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
const paragraphComponentLoader = {
|
|
990
|
+
match(element, returnableContentTypes) {
|
|
991
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
|
|
992
|
+
},
|
|
993
|
+
read(element, textbus, slotParser) {
|
|
994
|
+
let content;
|
|
995
|
+
if (/^P|H[1-6]$/.test(element.tagName)) {
|
|
996
|
+
content = element;
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
content = element.children[0];
|
|
1000
|
+
if (!content) {
|
|
1001
|
+
const p = document.createElement('p');
|
|
1002
|
+
p.append(element.innerText);
|
|
1003
|
+
content = p;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
const delta = slotParser(new core$1.Slot([
|
|
1007
|
+
core$1.ContentType.Text,
|
|
1008
|
+
core$1.ContentType.InlineComponent,
|
|
1009
|
+
core$1.ContentType.BlockComponent
|
|
1010
|
+
]), content).toDelta();
|
|
1011
|
+
const results = deltaToBlock(delta, textbus);
|
|
1012
|
+
if (results.length === 1) {
|
|
1013
|
+
return results[0];
|
|
1014
|
+
}
|
|
1015
|
+
const containerSlot = new core$1.Slot([
|
|
1016
|
+
core$1.ContentType.BlockComponent
|
|
1017
|
+
]);
|
|
1018
|
+
results.forEach(item => {
|
|
1019
|
+
containerSlot.insert(item);
|
|
1020
|
+
});
|
|
1021
|
+
return containerSlot;
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
function deltaToBlock(delta, textbus) {
|
|
1025
|
+
const results = [];
|
|
1026
|
+
let slot = null;
|
|
1027
|
+
for (const item of delta) {
|
|
1028
|
+
if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
|
|
1029
|
+
if (!slot) {
|
|
1030
|
+
slot = new core$1.Slot([
|
|
1031
|
+
core$1.ContentType.InlineComponent,
|
|
1032
|
+
core$1.ContentType.Text
|
|
1033
|
+
]);
|
|
1034
|
+
delta.attributes.forEach((value, key) => {
|
|
1035
|
+
slot.setAttribute(key, value);
|
|
1036
|
+
});
|
|
1037
|
+
results.push(new ParagraphComponent(textbus, {
|
|
1038
|
+
slot
|
|
1039
|
+
}));
|
|
1040
|
+
}
|
|
1041
|
+
slot.insert(item.insert, item.formats);
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
results.push(item.insert);
|
|
1045
|
+
slot = null;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return results;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
const languageList = [{
|
|
1052
|
+
label: 'JavaScript',
|
|
1053
|
+
value: 'JavaScript',
|
|
1054
|
+
}, {
|
|
665
1055
|
label: 'HTML',
|
|
666
1056
|
value: 'HTML',
|
|
667
1057
|
}, {
|
|
@@ -688,6 +1078,15 @@ const languageList = [{
|
|
|
688
1078
|
}, {
|
|
689
1079
|
label: 'Go',
|
|
690
1080
|
value: 'Go'
|
|
1081
|
+
}, {
|
|
1082
|
+
label: 'Kotlin',
|
|
1083
|
+
value: 'kotlin'
|
|
1084
|
+
}, {
|
|
1085
|
+
label: 'Python',
|
|
1086
|
+
value: 'python'
|
|
1087
|
+
}, {
|
|
1088
|
+
label: 'PHP',
|
|
1089
|
+
value: 'php'
|
|
691
1090
|
}, {
|
|
692
1091
|
label: 'JSON',
|
|
693
1092
|
value: 'JSON',
|
|
@@ -712,6 +1111,9 @@ const languageList = [{
|
|
|
712
1111
|
}, {
|
|
713
1112
|
label: 'Shell',
|
|
714
1113
|
value: 'shell',
|
|
1114
|
+
}, {
|
|
1115
|
+
label: 'Katex',
|
|
1116
|
+
value: 'latex',
|
|
715
1117
|
}, {
|
|
716
1118
|
label: 'Yaml',
|
|
717
1119
|
value: 'yaml',
|
|
@@ -730,11 +1132,16 @@ const languageList = [{
|
|
|
730
1132
|
}, {
|
|
731
1133
|
label: 'Dart',
|
|
732
1134
|
value: 'dart',
|
|
1135
|
+
}, {
|
|
1136
|
+
label: 'Rust',
|
|
1137
|
+
value: 'rust',
|
|
733
1138
|
}, {
|
|
734
1139
|
label: '',
|
|
735
1140
|
value: '',
|
|
736
1141
|
}];
|
|
737
1142
|
const sourceCodeThemes = [
|
|
1143
|
+
'xnote-dark',
|
|
1144
|
+
'xnote-dark-blue',
|
|
738
1145
|
'github',
|
|
739
1146
|
'atom-one-dark',
|
|
740
1147
|
'foundation',
|
|
@@ -790,12 +1197,17 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
790
1197
|
theme: json.theme
|
|
791
1198
|
});
|
|
792
1199
|
}
|
|
1200
|
+
getSlots() {
|
|
1201
|
+
return this.state.slots.map(i => i.slot);
|
|
1202
|
+
}
|
|
793
1203
|
setup() {
|
|
794
1204
|
const textbus = core$1.useContext();
|
|
795
1205
|
const selection = core$1.useContext(core$1.Selection);
|
|
796
1206
|
core$1.onBreak(ev => {
|
|
797
1207
|
const slots = this.state.slots;
|
|
798
|
-
|
|
1208
|
+
const parentComponent = selection.commonAncestorComponent;
|
|
1209
|
+
const parentSlot = parentComponent.parent;
|
|
1210
|
+
if (parentSlot && ev.target.isEmpty && ev.target === slots[slots.length - 1].slot) {
|
|
799
1211
|
const prevSlot = slots[slots.length - 2];
|
|
800
1212
|
if (prevSlot === null || prevSlot === void 0 ? void 0 : prevSlot.slot.isEmpty) {
|
|
801
1213
|
const slot = new core$1.Slot([
|
|
@@ -805,8 +1217,6 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
805
1217
|
const paragraph = new ParagraphComponent(textbus, {
|
|
806
1218
|
slot
|
|
807
1219
|
});
|
|
808
|
-
const parentComponent = selection.commonAncestorComponent;
|
|
809
|
-
const parentSlot = parentComponent.parent;
|
|
810
1220
|
const index = parentSlot.indexOf(parentComponent);
|
|
811
1221
|
parentSlot.retain(index + 1);
|
|
812
1222
|
slots.pop();
|
|
@@ -834,6 +1244,12 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
834
1244
|
});
|
|
835
1245
|
ev.preventDefault();
|
|
836
1246
|
});
|
|
1247
|
+
core$1.onSlotApplyFormat(ev => {
|
|
1248
|
+
ev.preventDefault();
|
|
1249
|
+
});
|
|
1250
|
+
core$1.onSlotSetAttribute(ev => {
|
|
1251
|
+
ev.preventDefault();
|
|
1252
|
+
});
|
|
837
1253
|
core$1.onPaste(ev => {
|
|
838
1254
|
const codeList = [];
|
|
839
1255
|
const sourceCode = ev.data.text;
|
|
@@ -911,7 +1327,7 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
911
1327
|
},
|
|
912
1328
|
action() {
|
|
913
1329
|
if (selection.isCollapsed) {
|
|
914
|
-
commander.insert('
|
|
1330
|
+
commander.insert(' ');
|
|
915
1331
|
return;
|
|
916
1332
|
}
|
|
917
1333
|
const blocks = selection.getBlocks();
|
|
@@ -957,11 +1373,15 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
957
1373
|
SourceCodeComponent.type = core$1.ContentType.BlockComponent;
|
|
958
1374
|
SourceCodeComponent.componentName = 'SourceCodeComponent';
|
|
959
1375
|
SourceCodeComponent.zenCoding = {
|
|
960
|
-
key: 'Enter',
|
|
961
|
-
match(c) {
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
1376
|
+
key: ['Enter', ' '],
|
|
1377
|
+
match(c, textbus) {
|
|
1378
|
+
const selection = textbus.get(core$1.Selection);
|
|
1379
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
1380
|
+
const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
|
|
1381
|
+
const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
|
|
1382
|
+
return reg.test(c);
|
|
1383
|
+
}
|
|
1384
|
+
return false;
|
|
965
1385
|
},
|
|
966
1386
|
createState(content) {
|
|
967
1387
|
const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
|
|
@@ -1028,7 +1448,7 @@ function SourceCodeView(props) {
|
|
|
1028
1448
|
}
|
|
1029
1449
|
const input = core.inject(platformBrowser.Input);
|
|
1030
1450
|
function updateCaret() {
|
|
1031
|
-
input.caret.refresh(
|
|
1451
|
+
input.caret.refresh();
|
|
1032
1452
|
}
|
|
1033
1453
|
const readonly = useReadonly();
|
|
1034
1454
|
const output = useOutput();
|
|
@@ -1065,33 +1485,11 @@ function SourceCodeView(props) {
|
|
|
1065
1485
|
}
|
|
1066
1486
|
}
|
|
1067
1487
|
}
|
|
1068
|
-
function nodesToVNodes(slot, nodes, index) {
|
|
1069
|
-
return nodes.map(i => {
|
|
1070
|
-
const location = {
|
|
1071
|
-
slot,
|
|
1072
|
-
startIndex: index,
|
|
1073
|
-
endIndex: index + i.textContent.length
|
|
1074
|
-
};
|
|
1075
|
-
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
1076
|
-
const childNodes = Array.from(i.childNodes);
|
|
1077
|
-
const vEle = core$1.createVNode('span', {
|
|
1078
|
-
class: i.className
|
|
1079
|
-
}, nodesToVNodes(slot, childNodes, index));
|
|
1080
|
-
index = location.endIndex;
|
|
1081
|
-
vEle.location = Object.assign({}, location);
|
|
1082
|
-
return vEle;
|
|
1083
|
-
}
|
|
1084
|
-
index = location.endIndex;
|
|
1085
|
-
const textNode = new core$1.VTextNode(i.textContent);
|
|
1086
|
-
textNode.location = location;
|
|
1087
|
-
return textNode;
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
1488
|
return (jsxRuntime.jsxs("div", { ref: props.rootRef, class: {
|
|
1091
1489
|
'xnote-source-code': true,
|
|
1092
1490
|
'xnote-source-code-line-number': state.lineNumber,
|
|
1093
1491
|
[state.theme || 'github']: true
|
|
1094
|
-
}, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [(!readonly() && !output()) && jsxRuntime.jsxs(ComponentToolbar, { visible: isFocus(), children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
|
|
1492
|
+
}, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak + '', "data-theme": state.theme || null, "data-line-number": state.lineNumber + '', children: [(!readonly() && !output()) && jsxRuntime.jsxs(ComponentToolbar, { visible: isFocus(), children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
|
|
1095
1493
|
return {
|
|
1096
1494
|
label: jsxRuntime.jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
|
|
1097
1495
|
value: item.value
|
|
@@ -1117,7 +1515,7 @@ function SourceCodeView(props) {
|
|
|
1117
1515
|
}
|
|
1118
1516
|
], children: [jsxRuntime.jsx("div", { class: "xnote-source-code-line-number-bg", style: {
|
|
1119
1517
|
width: Math.max(String(slots.length).length, 2.5) + 'em'
|
|
1120
|
-
} }), jsxRuntime.jsx("
|
|
1518
|
+
} }), jsxRuntime.jsx("pre", { onScroll: updateCaret, class: {
|
|
1121
1519
|
'xnote-source-code-content': true,
|
|
1122
1520
|
'xnote-source-code-content-highlight': blockHighlight
|
|
1123
1521
|
}, style: {
|
|
@@ -1138,7 +1536,7 @@ function SourceCodeView(props) {
|
|
|
1138
1536
|
children.push(br);
|
|
1139
1537
|
}
|
|
1140
1538
|
}
|
|
1141
|
-
return core$1.createVNode('
|
|
1539
|
+
return core$1.createVNode('div', {
|
|
1142
1540
|
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
|
|
1143
1541
|
}, [
|
|
1144
1542
|
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
@@ -1147,10 +1545,33 @@ function SourceCodeView(props) {
|
|
|
1147
1545
|
}) }), jsxRuntime.jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
|
|
1148
1546
|
};
|
|
1149
1547
|
}
|
|
1548
|
+
function nodesToVNodes(slot, nodes, index) {
|
|
1549
|
+
return nodes.map(i => {
|
|
1550
|
+
const location = {
|
|
1551
|
+
slot,
|
|
1552
|
+
startIndex: index,
|
|
1553
|
+
endIndex: index + i.textContent.length
|
|
1554
|
+
};
|
|
1555
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
1556
|
+
const childNodes = Array.from(i.childNodes);
|
|
1557
|
+
const vEle = core$1.createVNode('span', {
|
|
1558
|
+
class: i.className
|
|
1559
|
+
}, nodesToVNodes(slot, childNodes, index));
|
|
1560
|
+
index = location.endIndex;
|
|
1561
|
+
vEle.location = Object.assign({}, location);
|
|
1562
|
+
return vEle;
|
|
1563
|
+
}
|
|
1564
|
+
index = location.endIndex;
|
|
1565
|
+
const textNode = new core$1.VTextNode(i.textContent);
|
|
1566
|
+
textNode.location = location;
|
|
1567
|
+
return textNode;
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1150
1570
|
const sourceCodeComponentLoader = {
|
|
1151
|
-
match(element) {
|
|
1152
|
-
return
|
|
1153
|
-
element.tagName === '
|
|
1571
|
+
match(element, returnableContentTypes) {
|
|
1572
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
|
|
1573
|
+
((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
|
|
1574
|
+
element.tagName === 'PRE');
|
|
1154
1575
|
},
|
|
1155
1576
|
read(el, textbus) {
|
|
1156
1577
|
let slots = [];
|
|
@@ -1178,8 +1599,8 @@ const sourceCodeComponentLoader = {
|
|
|
1178
1599
|
return new SourceCodeComponent(textbus, {
|
|
1179
1600
|
lang: el.dataset.lang || '',
|
|
1180
1601
|
theme: el.dataset.theme || '',
|
|
1181
|
-
lineNumber:
|
|
1182
|
-
autoBreak:
|
|
1602
|
+
lineNumber: el.dataset.lineNumber === 'true',
|
|
1603
|
+
autoBreak: el.dataset.autoBreak === 'true',
|
|
1183
1604
|
slots
|
|
1184
1605
|
});
|
|
1185
1606
|
},
|
|
@@ -1278,15 +1699,26 @@ function AttrTool(props) {
|
|
|
1278
1699
|
textIndent: 0
|
|
1279
1700
|
});
|
|
1280
1701
|
function updateCheckStates() {
|
|
1281
|
-
|
|
1282
|
-
|
|
1702
|
+
if (!props.slot && !selection.isSelected) {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1283
1705
|
setCheckStates(draft => {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1706
|
+
const range = props.slot ? {
|
|
1707
|
+
startSlot: props.slot,
|
|
1708
|
+
endSlot: props.slot,
|
|
1709
|
+
startOffset: 0,
|
|
1710
|
+
endOffset: props.slot.length
|
|
1711
|
+
} : {
|
|
1712
|
+
startSlot: selection.startSlot,
|
|
1713
|
+
startOffset: selection.startOffset,
|
|
1714
|
+
endSlot: selection.endSlot,
|
|
1715
|
+
endOffset: selection.endOffset
|
|
1716
|
+
};
|
|
1717
|
+
const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
|
|
1718
|
+
const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
|
|
1286
1719
|
draft.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
|
|
1287
1720
|
draft.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
|
|
1288
1721
|
});
|
|
1289
|
-
(_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
1290
1722
|
}
|
|
1291
1723
|
updateCheckStates();
|
|
1292
1724
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
@@ -1333,150 +1765,84 @@ function AttrTool(props) {
|
|
|
1333
1765
|
break;
|
|
1334
1766
|
}
|
|
1335
1767
|
}
|
|
1336
|
-
return scopedCss.withScopedCSS(
|
|
1768
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
1337
1769
|
const states = checkStates();
|
|
1338
|
-
return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1770
|
+
return (jsxRuntime.jsx(Dropdown, { width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1339
1771
|
{
|
|
1340
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
1772
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', ctrlKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
1341
1773
|
value: 't-l'
|
|
1342
1774
|
}, {
|
|
1343
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
|
|
1775
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', ctrlKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
|
|
1344
1776
|
value: 't-r'
|
|
1345
1777
|
}, {
|
|
1346
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
|
|
1778
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', ctrlKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
|
|
1347
1779
|
value: 't-c'
|
|
1348
1780
|
}, {
|
|
1349
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
|
|
1781
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', ctrlKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
|
|
1350
1782
|
value: 't-j'
|
|
1351
1783
|
}, {
|
|
1352
1784
|
label: jsxRuntime.jsx(Divider, {}),
|
|
1353
1785
|
value: ''
|
|
1354
1786
|
}, {
|
|
1355
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
|
|
1787
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab' } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
|
|
1356
1788
|
value: 'i+'
|
|
1357
1789
|
}, {
|
|
1358
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
|
|
1790
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
|
|
1359
1791
|
value: 'i-'
|
|
1360
1792
|
}
|
|
1361
1793
|
], children: props.children || jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
|
|
1362
1794
|
});
|
|
1363
1795
|
}
|
|
1364
1796
|
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
|
|
1797
|
+
const defaultRowHeight = 30;
|
|
1798
|
+
const defaultColumnWidth = 100;
|
|
1799
|
+
class TableComponent extends core$1.Component {
|
|
1800
|
+
static fromJSON(textbus, json) {
|
|
1801
|
+
const registry = textbus.get(core$1.Registry);
|
|
1802
|
+
return new TableComponent(textbus, {
|
|
1803
|
+
layoutWidth: json.layoutWidth || [],
|
|
1804
|
+
rows: json.rows.map(row => {
|
|
1805
|
+
return {
|
|
1806
|
+
height: row.height,
|
|
1807
|
+
cells: row.cells.map(cell => {
|
|
1808
|
+
return {
|
|
1809
|
+
colspan: cell.colspan,
|
|
1810
|
+
rowspan: cell.rowspan,
|
|
1811
|
+
slot: registry.createSlot(cell.slot)
|
|
1812
|
+
};
|
|
1813
|
+
})
|
|
1814
|
+
};
|
|
1815
|
+
})
|
|
1816
|
+
});
|
|
1368
1817
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1818
|
+
constructor(textbus, state = {
|
|
1819
|
+
layoutWidth: Array.from({ length: 5 }).fill(100),
|
|
1820
|
+
rows: Array.from({ length: 3 }).map(() => {
|
|
1821
|
+
return {
|
|
1822
|
+
height: defaultRowHeight,
|
|
1823
|
+
cells: Array.from({ length: 5 }).map(() => {
|
|
1824
|
+
const p = new ParagraphComponent(textbus);
|
|
1825
|
+
const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
|
|
1826
|
+
slot.insert(p);
|
|
1827
|
+
return {
|
|
1828
|
+
rowspan: 1,
|
|
1829
|
+
colspan: 1,
|
|
1830
|
+
slot
|
|
1831
|
+
};
|
|
1832
|
+
})
|
|
1833
|
+
};
|
|
1834
|
+
})
|
|
1835
|
+
}) {
|
|
1836
|
+
super(textbus, state);
|
|
1837
|
+
this.selection = this.textbus.get(core$1.Selection);
|
|
1838
|
+
this.focus = new core$1.Subject();
|
|
1839
|
+
this.tableSelection = core.createSignal(null);
|
|
1379
1840
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const keyboard = textbus.get(core$1.Keyboard);
|
|
1383
|
-
const commander = textbus.get(core$1.Commander);
|
|
1384
|
-
const selection = textbus.get(core$1.Selection);
|
|
1385
|
-
keyboard.addShortcut({
|
|
1386
|
-
keymap: {
|
|
1387
|
-
key: '123456'.split(''),
|
|
1388
|
-
ctrlKey: true
|
|
1389
|
-
},
|
|
1390
|
-
action(key) {
|
|
1391
|
-
commander.applyAttribute(headingAttr, 'h' + key);
|
|
1392
|
-
}
|
|
1393
|
-
});
|
|
1394
|
-
keyboard.addZenCodingInterceptor({
|
|
1395
|
-
match(content) {
|
|
1396
|
-
return /^#{1,6}$/.test(content);
|
|
1397
|
-
},
|
|
1398
|
-
try(key) {
|
|
1399
|
-
return key === ' ';
|
|
1400
|
-
},
|
|
1401
|
-
action(content) {
|
|
1402
|
-
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
1403
|
-
commonAncestorSlot.cut();
|
|
1404
|
-
commander.applyAttribute(headingAttr, 'h' + content.length);
|
|
1405
|
-
return true;
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
function useBlockContent(slot) {
|
|
1411
|
-
const textbus = core$1.useContext();
|
|
1412
|
-
const selection = textbus.get(core$1.Selection);
|
|
1413
|
-
core$1.onBreak(ev => {
|
|
1414
|
-
if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
|
|
1415
|
-
const p = new ParagraphComponent(textbus);
|
|
1416
|
-
ev.target.insert(p);
|
|
1417
|
-
selection.setPosition(p.state.slot, 0);
|
|
1418
|
-
ev.preventDefault();
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
core$1.onContentInsert(ev => {
|
|
1422
|
-
if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
|
|
1423
|
-
(typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
|
|
1424
|
-
const p = new ParagraphComponent(textbus);
|
|
1425
|
-
const childSlot = p.state.slot;
|
|
1426
|
-
childSlot.insert(ev.data.content);
|
|
1427
|
-
ev.target.insert(p);
|
|
1428
|
-
selection.setPosition(childSlot, childSlot.index);
|
|
1429
|
-
ev.preventDefault();
|
|
1430
|
-
}
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
const defaultRowHeight = 30;
|
|
1435
|
-
const defaultColumnWidth = 100;
|
|
1436
|
-
class TableComponent extends core$1.Component {
|
|
1437
|
-
static fromJSON(textbus, json) {
|
|
1438
|
-
const registry = textbus.get(core$1.Registry);
|
|
1439
|
-
return new TableComponent(textbus, {
|
|
1440
|
-
layoutWidth: json.layoutWidth || [],
|
|
1441
|
-
rows: json.rows.map(row => {
|
|
1442
|
-
return {
|
|
1443
|
-
height: row.height,
|
|
1444
|
-
cells: row.cells.map(cell => {
|
|
1445
|
-
return {
|
|
1446
|
-
colspan: cell.colspan,
|
|
1447
|
-
rowspan: cell.rowspan,
|
|
1448
|
-
slot: registry.createSlot(cell.slot)
|
|
1449
|
-
};
|
|
1450
|
-
})
|
|
1451
|
-
};
|
|
1452
|
-
})
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
constructor(textbus, state = {
|
|
1456
|
-
layoutWidth: Array.from({ length: 3 }).fill(100),
|
|
1457
|
-
rows: Array.from({ length: 3 }).map(() => {
|
|
1458
|
-
return {
|
|
1459
|
-
height: defaultRowHeight,
|
|
1460
|
-
cells: Array.from({ length: 3 }).map(() => {
|
|
1461
|
-
return {
|
|
1462
|
-
rowspan: 1,
|
|
1463
|
-
colspan: 1,
|
|
1464
|
-
slot: new core$1.Slot([
|
|
1465
|
-
core$1.ContentType.Text,
|
|
1466
|
-
core$1.ContentType.InlineComponent,
|
|
1467
|
-
core$1.ContentType.BlockComponent
|
|
1468
|
-
])
|
|
1469
|
-
};
|
|
1470
|
-
})
|
|
1471
|
-
};
|
|
1472
|
-
})
|
|
1473
|
-
}) {
|
|
1474
|
-
super(textbus, state);
|
|
1475
|
-
this.selection = this.textbus.get(core$1.Selection);
|
|
1476
|
-
this.focus = new core$1.Subject();
|
|
1477
|
-
this.tableSelection = core.createSignal(null);
|
|
1841
|
+
getSlots() {
|
|
1842
|
+
return this.state.rows.map(i => i.cells.map(j => j.slot)).flat();
|
|
1478
1843
|
}
|
|
1479
1844
|
setup() {
|
|
1845
|
+
const selection = core$1.useContext(core$1.Selection);
|
|
1480
1846
|
core$1.onFocusIn(() => {
|
|
1481
1847
|
this.focus.next(true);
|
|
1482
1848
|
});
|
|
@@ -1486,12 +1852,42 @@ class TableComponent extends core$1.Component {
|
|
|
1486
1852
|
useBlockContent((slot) => {
|
|
1487
1853
|
return slot.parent === this;
|
|
1488
1854
|
});
|
|
1489
|
-
|
|
1490
|
-
|
|
1855
|
+
const sub = selection.onChange.subscribe(() => {
|
|
1856
|
+
if (selection.commonAncestorComponent !== this || selection.isCollapsed) {
|
|
1857
|
+
this.tableSelection.set(null);
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1860
|
+
core$1.onDestroy(() => {
|
|
1861
|
+
sub.unsubscribe();
|
|
1862
|
+
});
|
|
1863
|
+
const findPosition = (slot) => {
|
|
1864
|
+
let cell = slot;
|
|
1865
|
+
while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== this) {
|
|
1866
|
+
cell = cell.parentSlot;
|
|
1867
|
+
}
|
|
1868
|
+
if (cell) {
|
|
1869
|
+
const rows = this.state.rows;
|
|
1870
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
1871
|
+
const row = rows[rowIndex].cells;
|
|
1872
|
+
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
|
1873
|
+
const item = row[colIndex].slot;
|
|
1874
|
+
if (item === cell) {
|
|
1875
|
+
return {
|
|
1876
|
+
rowIndex,
|
|
1877
|
+
colIndex
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
return null;
|
|
1884
|
+
};
|
|
1885
|
+
const select = (ev, selectPosition) => {
|
|
1886
|
+
this.tableSelection.set(selectPosition);
|
|
1491
1887
|
if (selectPosition) {
|
|
1492
1888
|
const cells = [];
|
|
1493
|
-
this.state.rows.slice(selectPosition.startRow, selectPosition.endRow
|
|
1494
|
-
cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn
|
|
1889
|
+
this.state.rows.slice(selectPosition.startRow, selectPosition.endRow).forEach(row => {
|
|
1890
|
+
cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn).map(i => i.slot));
|
|
1495
1891
|
});
|
|
1496
1892
|
ev.useRanges(cells.map(i => {
|
|
1497
1893
|
return {
|
|
@@ -1502,33 +1898,64 @@ class TableComponent extends core$1.Component {
|
|
|
1502
1898
|
}));
|
|
1503
1899
|
ev.preventDefault();
|
|
1504
1900
|
}
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
});
|
|
1521
|
-
slot.insert(p);
|
|
1522
|
-
if (slot === selection.anchorSlot) {
|
|
1523
|
-
selection.setAnchor(childSlot, 0);
|
|
1524
|
-
}
|
|
1525
|
-
if (slot === selection.focusSlot) {
|
|
1526
|
-
selection.setFocus(childSlot, 0);
|
|
1901
|
+
};
|
|
1902
|
+
core$1.onGetRanges(ev => {
|
|
1903
|
+
var _a;
|
|
1904
|
+
const startPosition = findPosition(selection.startSlot);
|
|
1905
|
+
const endPosition = findPosition(selection.endSlot);
|
|
1906
|
+
if (startPosition && endPosition) {
|
|
1907
|
+
if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
|
|
1908
|
+
if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1909
|
+
select(ev, {
|
|
1910
|
+
startColumn: startPosition.colIndex,
|
|
1911
|
+
startRow: startPosition.rowIndex,
|
|
1912
|
+
endColumn: endPosition.colIndex + 1,
|
|
1913
|
+
endRow: endPosition.rowIndex + 1
|
|
1914
|
+
});
|
|
1915
|
+
return;
|
|
1527
1916
|
}
|
|
1917
|
+
select(ev, null);
|
|
1918
|
+
return;
|
|
1528
1919
|
}
|
|
1529
|
-
|
|
1920
|
+
const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
|
|
1921
|
+
const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
|
|
1922
|
+
select(ev, {
|
|
1923
|
+
startColumn,
|
|
1924
|
+
startRow,
|
|
1925
|
+
endColumn: endColumn + 1,
|
|
1926
|
+
endRow: endRow + 1
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
else {
|
|
1930
|
+
select(ev, null);
|
|
1931
|
+
}
|
|
1530
1932
|
});
|
|
1531
1933
|
}
|
|
1934
|
+
// afterContentCheck() {
|
|
1935
|
+
// const selection = this.selection
|
|
1936
|
+
// const rows = this.state.rows
|
|
1937
|
+
// rows.forEach(row => {
|
|
1938
|
+
// row.cells.forEach(cell => {
|
|
1939
|
+
// const slot = cell.slot
|
|
1940
|
+
// if (slot.isEmpty) {
|
|
1941
|
+
// const childSlot = new Slot([
|
|
1942
|
+
// ContentType.Text,
|
|
1943
|
+
// ContentType.InlineComponent
|
|
1944
|
+
// ])
|
|
1945
|
+
// const p = new ParagraphComponent(this.textbus, {
|
|
1946
|
+
// slot: childSlot
|
|
1947
|
+
// })
|
|
1948
|
+
// slot.insert(p)
|
|
1949
|
+
// if (slot === selection.anchorSlot) {
|
|
1950
|
+
// selection.setAnchor(childSlot, 0)
|
|
1951
|
+
// }
|
|
1952
|
+
// if (slot === selection.focusSlot) {
|
|
1953
|
+
// selection.setFocus(childSlot, 0)
|
|
1954
|
+
// }
|
|
1955
|
+
// }
|
|
1956
|
+
// })
|
|
1957
|
+
// })
|
|
1958
|
+
// }
|
|
1532
1959
|
deleteColumn(index) {
|
|
1533
1960
|
this.state.layoutWidth.splice(index, 1);
|
|
1534
1961
|
this.state.rows.forEach(row => {
|
|
@@ -1545,8 +1972,6 @@ class TableComponent extends core$1.Component {
|
|
|
1545
1972
|
this.state.rows.forEach(row => {
|
|
1546
1973
|
const slot = new core$1.Slot([
|
|
1547
1974
|
core$1.ContentType.BlockComponent,
|
|
1548
|
-
core$1.ContentType.InlineComponent,
|
|
1549
|
-
core$1.ContentType.Text
|
|
1550
1975
|
]);
|
|
1551
1976
|
slot.insert(new ParagraphComponent(this.textbus, {
|
|
1552
1977
|
slot: new core$1.Slot([
|
|
@@ -1574,8 +1999,6 @@ class TableComponent extends core$1.Component {
|
|
|
1574
1999
|
cells: this.state.layoutWidth.map(() => {
|
|
1575
2000
|
const slot = new core$1.Slot([
|
|
1576
2001
|
core$1.ContentType.BlockComponent,
|
|
1577
|
-
core$1.ContentType.InlineComponent,
|
|
1578
|
-
core$1.ContentType.Text
|
|
1579
2002
|
]);
|
|
1580
2003
|
slot.insert(new ParagraphComponent(this.textbus, {
|
|
1581
2004
|
slot: new core$1.Slot([
|
|
@@ -1637,7 +2060,7 @@ function registerStrikeThroughShortcut(textbus) {
|
|
|
1637
2060
|
}
|
|
1638
2061
|
const strikeThroughFormatLoader = {
|
|
1639
2062
|
match(element) {
|
|
1640
|
-
return
|
|
2063
|
+
return /^(strike|del|s)$/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
|
|
1641
2064
|
},
|
|
1642
2065
|
read() {
|
|
1643
2066
|
return {
|
|
@@ -1655,12 +2078,16 @@ class TodolistComponent extends core$1.Component {
|
|
|
1655
2078
|
checked: json.checked
|
|
1656
2079
|
});
|
|
1657
2080
|
}
|
|
2081
|
+
getSlots() {
|
|
2082
|
+
return [this.state.slot];
|
|
2083
|
+
}
|
|
1658
2084
|
setup() {
|
|
1659
2085
|
const textbus = core$1.useContext();
|
|
1660
2086
|
const commander = core$1.useContext(core$1.Commander);
|
|
1661
2087
|
const selection = core$1.useContext(core$1.Selection);
|
|
1662
2088
|
core$1.onBreak(ev => {
|
|
1663
2089
|
const slot = ev.target.cut(ev.data.index);
|
|
2090
|
+
slot.removeAttribute(headingAttr);
|
|
1664
2091
|
if (ev.target.isEmpty && slot.isEmpty) {
|
|
1665
2092
|
const beforeIndex = this.parent.indexOf(this);
|
|
1666
2093
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
@@ -1708,21 +2135,32 @@ class TodolistComponent extends core$1.Component {
|
|
|
1708
2135
|
TodolistComponent.type = core$1.ContentType.BlockComponent;
|
|
1709
2136
|
TodolistComponent.componentName = 'TodoListComponent';
|
|
1710
2137
|
TodolistComponent.zenCoding = {
|
|
1711
|
-
match
|
|
2138
|
+
match(content, textbus) {
|
|
2139
|
+
const selection = textbus.get(core$1.Selection);
|
|
2140
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
2141
|
+
return /^\[(x|\s)?\]$/.test(content);
|
|
2142
|
+
}
|
|
2143
|
+
return false;
|
|
2144
|
+
},
|
|
1712
2145
|
key: ' ',
|
|
1713
|
-
createState(content) {
|
|
2146
|
+
createState(content, textbus) {
|
|
2147
|
+
const selection = textbus.get(core$1.Selection);
|
|
2148
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2149
|
+
const slot = new core$1.Slot([
|
|
2150
|
+
core$1.ContentType.InlineComponent,
|
|
2151
|
+
core$1.ContentType.Text
|
|
2152
|
+
]);
|
|
2153
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
2154
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
2155
|
+
}
|
|
1714
2156
|
const isChecked = content.charAt(1) === 'x';
|
|
1715
2157
|
return {
|
|
1716
2158
|
checked: isChecked,
|
|
1717
|
-
slot
|
|
1718
|
-
core$1.ContentType.InlineComponent,
|
|
1719
|
-
core$1.ContentType.Text
|
|
1720
|
-
])
|
|
2159
|
+
slot
|
|
1721
2160
|
};
|
|
1722
2161
|
}
|
|
1723
2162
|
};
|
|
1724
2163
|
function TodolistView(props) {
|
|
1725
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
1726
2164
|
const component = props.component;
|
|
1727
2165
|
const state = component.state;
|
|
1728
2166
|
function toggle() {
|
|
@@ -1751,11 +2189,7 @@ function TodolistView(props) {
|
|
|
1751
2189
|
marginLeft: indent * 24 + 'px',
|
|
1752
2190
|
justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
|
|
1753
2191
|
textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
|
|
1754
|
-
}, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }),
|
|
1755
|
-
return core$1.createVNode('div', {
|
|
1756
|
-
class: 'xnote-todolist-content'
|
|
1757
|
-
}, children);
|
|
1758
|
-
}, readonly())] }));
|
|
2192
|
+
}, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'div', class: 'xnote-todolist-content', renderEnv: readonly() || output() })] }));
|
|
1759
2193
|
};
|
|
1760
2194
|
}
|
|
1761
2195
|
const todolistComponentLoader = {
|
|
@@ -1774,75 +2208,40 @@ const todolistComponentLoader = {
|
|
|
1774
2208
|
}
|
|
1775
2209
|
};
|
|
1776
2210
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1784
|
-
constructor(textbus, state = {
|
|
1785
|
-
slot: new core$1.Slot([
|
|
1786
|
-
core$1.ContentType.Text,
|
|
1787
|
-
core$1.ContentType.InlineComponent,
|
|
1788
|
-
core$1.ContentType.BlockComponent
|
|
1789
|
-
])
|
|
1790
|
-
}) {
|
|
1791
|
-
super(textbus, state);
|
|
1792
|
-
}
|
|
1793
|
-
setup() {
|
|
1794
|
-
useBlockContent(this.state.slot);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
BlockquoteComponent.type = core$1.ContentType.BlockComponent;
|
|
1798
|
-
BlockquoteComponent.componentName = 'BlockquoteComponent';
|
|
1799
|
-
BlockquoteComponent.zenCoding = {
|
|
1800
|
-
key: ' ',
|
|
1801
|
-
match: /^>$/,
|
|
1802
|
-
createState() {
|
|
1803
|
-
return {
|
|
1804
|
-
slot: new core$1.Slot([
|
|
1805
|
-
core$1.ContentType.Text,
|
|
2211
|
+
function toList(textbus, type) {
|
|
2212
|
+
const commander = textbus.get(core$1.Commander);
|
|
2213
|
+
commander.transform({
|
|
2214
|
+
targetType: ListComponent.type,
|
|
2215
|
+
slotFactory() {
|
|
2216
|
+
return new core$1.Slot([
|
|
1806
2217
|
core$1.ContentType.InlineComponent,
|
|
1807
|
-
core$1.ContentType.
|
|
1808
|
-
])
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
2218
|
+
core$1.ContentType.Text
|
|
2219
|
+
]);
|
|
2220
|
+
},
|
|
2221
|
+
stateFactory(slots) {
|
|
2222
|
+
return slots.map((slot, index) => {
|
|
2223
|
+
return new ListComponent(textbus, {
|
|
2224
|
+
type,
|
|
2225
|
+
reorder: index === 0,
|
|
2226
|
+
slot
|
|
2227
|
+
});
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
function registerListShortcut(textbus) {
|
|
2233
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
2234
|
+
keyboard.addShortcut({
|
|
2235
|
+
keymap: {
|
|
2236
|
+
key: ['o', 'u'],
|
|
2237
|
+
ctrlKey: true,
|
|
2238
|
+
shiftKey: true
|
|
2239
|
+
},
|
|
2240
|
+
action(key) {
|
|
2241
|
+
toList(textbus, key === 'o' ? 'OrderedList' : 'UnorderedList');
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
1821
2244
|
}
|
|
1822
|
-
const blockquoteComponentLoader = {
|
|
1823
|
-
match(element) {
|
|
1824
|
-
return element.tagName === 'BLOCKQUOTE';
|
|
1825
|
-
},
|
|
1826
|
-
read(element, textbus, slotParser) {
|
|
1827
|
-
const delta = slotParser(new core$1.Slot([
|
|
1828
|
-
core$1.ContentType.Text,
|
|
1829
|
-
core$1.ContentType.BlockComponent,
|
|
1830
|
-
core$1.ContentType.InlineComponent
|
|
1831
|
-
]), element).toDelta();
|
|
1832
|
-
const slot = new core$1.Slot([
|
|
1833
|
-
core$1.ContentType.BlockComponent,
|
|
1834
|
-
core$1.ContentType.InlineComponent,
|
|
1835
|
-
core$1.ContentType.Text
|
|
1836
|
-
]);
|
|
1837
|
-
deltaToBlock(delta, textbus).forEach(i => {
|
|
1838
|
-
slot.insert(i);
|
|
1839
|
-
});
|
|
1840
|
-
return new BlockquoteComponent(textbus, {
|
|
1841
|
-
slot
|
|
1842
|
-
});
|
|
1843
|
-
},
|
|
1844
|
-
};
|
|
1845
|
-
|
|
1846
2245
|
class ListComponent extends core$1.Component {
|
|
1847
2246
|
static fromJSON(textbus, json) {
|
|
1848
2247
|
return new ListComponent(textbus, {
|
|
@@ -1851,6 +2250,9 @@ class ListComponent extends core$1.Component {
|
|
|
1851
2250
|
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
1852
2251
|
});
|
|
1853
2252
|
}
|
|
2253
|
+
getSlots() {
|
|
2254
|
+
return [this.state.slot];
|
|
2255
|
+
}
|
|
1854
2256
|
setup() {
|
|
1855
2257
|
const textbus = core$1.useContext();
|
|
1856
2258
|
const commander = core$1.useContext(core$1.Commander);
|
|
@@ -1864,8 +2266,7 @@ class ListComponent extends core$1.Component {
|
|
|
1864
2266
|
const afterContent = parentSlot.sliceContent(index + 1);
|
|
1865
2267
|
for (const item of afterContent) {
|
|
1866
2268
|
if (item instanceof ListComponent &&
|
|
1867
|
-
item.state.type === 'OrderedList'
|
|
1868
|
-
item.state.slot.getAttribute(textIndentAttr) === this.state.slot.getAttribute(textIndentAttr)) {
|
|
2269
|
+
item.state.type === 'OrderedList') {
|
|
1869
2270
|
if (item.state.reorder) {
|
|
1870
2271
|
break;
|
|
1871
2272
|
}
|
|
@@ -1878,6 +2279,7 @@ class ListComponent extends core$1.Component {
|
|
|
1878
2279
|
});
|
|
1879
2280
|
core$1.onBreak(ev => {
|
|
1880
2281
|
const slot = ev.target.cut(ev.data.index);
|
|
2282
|
+
slot.removeAttribute(headingAttr);
|
|
1881
2283
|
if (ev.target.isEmpty && slot.isEmpty) {
|
|
1882
2284
|
const beforeIndex = this.parent.indexOf(this);
|
|
1883
2285
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
@@ -1923,21 +2325,52 @@ class ListComponent extends core$1.Component {
|
|
|
1923
2325
|
selection.setPosition(slot, 0);
|
|
1924
2326
|
}
|
|
1925
2327
|
});
|
|
2328
|
+
core$1.useDynamicShortcut({
|
|
2329
|
+
keymap: {
|
|
2330
|
+
key: 'Tab'
|
|
2331
|
+
},
|
|
2332
|
+
action: () => {
|
|
2333
|
+
Promise.resolve().then(() => updateAfterList(this));
|
|
2334
|
+
return false;
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
core$1.useDynamicShortcut({
|
|
2338
|
+
keymap: {
|
|
2339
|
+
key: 'Tab',
|
|
2340
|
+
shiftKey: true
|
|
2341
|
+
},
|
|
2342
|
+
action: () => {
|
|
2343
|
+
Promise.resolve().then(() => updateAfterList(this));
|
|
2344
|
+
return false;
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
1926
2347
|
}
|
|
1927
2348
|
}
|
|
1928
2349
|
ListComponent.componentName = 'ListComponent';
|
|
1929
2350
|
ListComponent.type = core$1.ContentType.BlockComponent;
|
|
1930
2351
|
ListComponent.zenCoding = {
|
|
1931
2352
|
key: ' ',
|
|
1932
|
-
match
|
|
1933
|
-
|
|
2353
|
+
match(content, textbus) {
|
|
2354
|
+
const selection = textbus.get(core$1.Selection);
|
|
2355
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
2356
|
+
return /^([1-9]\.|[+*-])$/.test(content);
|
|
2357
|
+
}
|
|
2358
|
+
return false;
|
|
2359
|
+
},
|
|
2360
|
+
createState(content, textbus) {
|
|
2361
|
+
const selection = textbus.get(core$1.Selection);
|
|
2362
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2363
|
+
const slot = new core$1.Slot([
|
|
2364
|
+
core$1.ContentType.InlineComponent,
|
|
2365
|
+
core$1.ContentType.Text
|
|
2366
|
+
]);
|
|
2367
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
2368
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
2369
|
+
}
|
|
1934
2370
|
return {
|
|
1935
2371
|
type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
|
|
1936
2372
|
reorder: true,
|
|
1937
|
-
slot
|
|
1938
|
-
core$1.ContentType.InlineComponent,
|
|
1939
|
-
core$1.ContentType.Text
|
|
1940
|
-
])
|
|
2373
|
+
slot
|
|
1941
2374
|
};
|
|
1942
2375
|
}
|
|
1943
2376
|
};
|
|
@@ -1959,7 +2392,6 @@ function numberToLetter(num) {
|
|
|
1959
2392
|
}).join('');
|
|
1960
2393
|
}
|
|
1961
2394
|
function ListComponentView(props) {
|
|
1962
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
1963
2395
|
const component = props.component;
|
|
1964
2396
|
function reorder(is) {
|
|
1965
2397
|
component.state.reorder = is;
|
|
@@ -1986,7 +2418,8 @@ function ListComponentView(props) {
|
|
|
1986
2418
|
return () => {
|
|
1987
2419
|
const ListType = component.state.type === 'UnorderedList' ? 'ul' : 'ol';
|
|
1988
2420
|
const ulIcons = ['•', '◦', '▪'];
|
|
1989
|
-
let icon
|
|
2421
|
+
let icon;
|
|
2422
|
+
let listStep = 0;
|
|
1990
2423
|
const indent = component.state.slot.getAttribute(textIndentAttr) || 0;
|
|
1991
2424
|
if (ListType === 'ul') {
|
|
1992
2425
|
icon = ulIcons[indent % 3];
|
|
@@ -1994,7 +2427,6 @@ function ListComponentView(props) {
|
|
|
1994
2427
|
else {
|
|
1995
2428
|
const parentSlot = component.parent;
|
|
1996
2429
|
const index = parentSlot.indexOf(component);
|
|
1997
|
-
let listStep = 0;
|
|
1998
2430
|
if (!component.state.reorder) {
|
|
1999
2431
|
const beforeContent = parentSlot.sliceContent(0, index);
|
|
2000
2432
|
while (beforeContent.length) {
|
|
@@ -2025,7 +2457,7 @@ function ListComponentView(props) {
|
|
|
2025
2457
|
icon = numberToLetter(listStep) + '.';
|
|
2026
2458
|
}
|
|
2027
2459
|
}
|
|
2028
|
-
return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, class: "xnote-list", style: {
|
|
2460
|
+
return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, "data-reorder": (listStep === 0) + '', class: "xnote-list", style: {
|
|
2029
2461
|
marginLeft: indent * 24 + 'px'
|
|
2030
2462
|
}, children: jsxRuntime.jsxs("li", { style: {
|
|
2031
2463
|
justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
|
|
@@ -2033,16 +2465,12 @@ function ListComponentView(props) {
|
|
|
2033
2465
|
}, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
|
|
2034
2466
|
jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
|
|
2035
2467
|
:
|
|
2036
|
-
jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }),
|
|
2037
|
-
return core$1.createVNode('div', {
|
|
2038
|
-
class: 'xnote-list-content'
|
|
2039
|
-
}, children);
|
|
2040
|
-
}, readonly())] }) }));
|
|
2468
|
+
jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), jsxRuntime.jsx(SlotRender, { slot: component.state.slot, class: 'xnote-list-content', renderEnv: readonly() || output() })] }) }));
|
|
2041
2469
|
};
|
|
2042
2470
|
}
|
|
2043
2471
|
const listComponentLoader = {
|
|
2044
|
-
match(element) {
|
|
2045
|
-
return element.tagName === 'UL' || element.tagName === 'OL';
|
|
2472
|
+
match(element, returnableContentTypes) {
|
|
2473
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.tagName === 'UL' || element.tagName === 'OL');
|
|
2046
2474
|
},
|
|
2047
2475
|
read(element, textbus, slotParser) {
|
|
2048
2476
|
const type = element.tagName === 'OL' ? 'OrderedList' : 'UnorderedList';
|
|
@@ -2053,7 +2481,7 @@ const listComponentLoader = {
|
|
|
2053
2481
|
]), element.querySelector('.xnote-list-content') || document.createElement('div'));
|
|
2054
2482
|
return new ListComponent(textbus, {
|
|
2055
2483
|
slot,
|
|
2056
|
-
reorder:
|
|
2484
|
+
reorder: element.dataset.reorder !== 'false',
|
|
2057
2485
|
type
|
|
2058
2486
|
});
|
|
2059
2487
|
}
|
|
@@ -2096,125 +2524,58 @@ function useActiveBlock() {
|
|
|
2096
2524
|
sourceCode: false,
|
|
2097
2525
|
highlightBox: false
|
|
2098
2526
|
});
|
|
2099
|
-
function updateCheckStates() {
|
|
2527
|
+
function updateCheckStates(range) {
|
|
2100
2528
|
setCheckStates(draft => {
|
|
2101
|
-
const heading = query.
|
|
2102
|
-
draft.paragraph = query.
|
|
2529
|
+
const heading = query.queryAttributeByRange(headingAttr, range);
|
|
2530
|
+
draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2103
2531
|
draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
|
|
2104
2532
|
if (heading.state === core$1.QueryStateType.Enabled) {
|
|
2105
2533
|
draft[heading.value] = true;
|
|
2106
2534
|
draft.paragraph = false;
|
|
2107
2535
|
}
|
|
2108
|
-
const queryList = query.
|
|
2536
|
+
const queryList = query.queryComponentByRange(ListComponent, range);
|
|
2109
2537
|
draft.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
|
|
2110
2538
|
draft.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
|
|
2111
|
-
draft.table = query.
|
|
2112
|
-
draft.todolist = query.
|
|
2113
|
-
draft.blockquote = query.
|
|
2114
|
-
draft.sourceCode = query.
|
|
2539
|
+
draft.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2540
|
+
draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2541
|
+
draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2542
|
+
draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2115
2543
|
});
|
|
2116
2544
|
}
|
|
2117
|
-
updateCheckStates();
|
|
2118
2545
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
2119
|
-
|
|
2546
|
+
if (!selection.isSelected) {
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
updateCheckStates({
|
|
2550
|
+
startOffset: selection.startOffset,
|
|
2551
|
+
startSlot: selection.startSlot,
|
|
2552
|
+
endSlot: selection.endSlot,
|
|
2553
|
+
endOffset: selection.endOffset
|
|
2554
|
+
});
|
|
2120
2555
|
});
|
|
2121
2556
|
core.onUnmounted(() => {
|
|
2122
2557
|
subscription.unsubscribe();
|
|
2123
2558
|
});
|
|
2124
2559
|
return function (slot = null) {
|
|
2125
2560
|
if (slot) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2561
|
+
updateCheckStates({
|
|
2562
|
+
startOffset: 0,
|
|
2563
|
+
endOffset: slot.length,
|
|
2564
|
+
startSlot: slot,
|
|
2565
|
+
endSlot: slot
|
|
2566
|
+
});
|
|
2130
2567
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
type: json.type,
|
|
2139
|
-
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
2140
|
-
});
|
|
2141
|
-
}
|
|
2142
|
-
constructor(textbus, state = {
|
|
2143
|
-
type: '',
|
|
2144
|
-
slot: new core$1.Slot([
|
|
2145
|
-
core$1.ContentType.BlockComponent,
|
|
2146
|
-
core$1.ContentType.InlineComponent,
|
|
2147
|
-
core$1.ContentType.Text
|
|
2148
|
-
])
|
|
2149
|
-
}) {
|
|
2150
|
-
super(textbus, state);
|
|
2151
|
-
}
|
|
2152
|
-
setup() {
|
|
2153
|
-
useBlockContent(this.state.slot);
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
|
|
2157
|
-
HighlightBoxComponent.componentName = 'HighlightBoxComponent';
|
|
2158
|
-
HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
|
|
2159
|
-
function HighlightBoxView(props) {
|
|
2160
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
2161
|
-
const readonly = useReadonly();
|
|
2162
|
-
const output = useOutput();
|
|
2163
|
-
const emoji = [];
|
|
2164
|
-
for (let i = 0x1F600; i <= 0x1F64F; i++) {
|
|
2165
|
-
emoji.push(i);
|
|
2166
|
-
}
|
|
2167
|
-
const dropdownRef = core.createRef();
|
|
2168
|
-
function setType(type) {
|
|
2169
|
-
var _a;
|
|
2170
|
-
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
2171
|
-
props.component.state.type = type;
|
|
2172
|
-
}
|
|
2173
|
-
return () => {
|
|
2174
|
-
const { state, name } = props.component;
|
|
2175
|
-
if (readonly() || output()) {
|
|
2176
|
-
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
|
|
2177
|
-
return core$1.createVNode('div', {
|
|
2178
|
-
class: 'xnote-highlight-box-content'
|
|
2179
|
-
}, children);
|
|
2180
|
-
}, readonly())] }));
|
|
2568
|
+
else if (selection.isSelected) {
|
|
2569
|
+
updateCheckStates({
|
|
2570
|
+
startOffset: selection.startOffset,
|
|
2571
|
+
startSlot: selection.startSlot,
|
|
2572
|
+
endSlot: selection.endSlot,
|
|
2573
|
+
endOffset: selection.endOffset
|
|
2574
|
+
});
|
|
2181
2575
|
}
|
|
2182
|
-
return (
|
|
2183
|
-
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
2184
|
-
}), jsxRuntime.jsx(Divider, {}), emoji.map(i => {
|
|
2185
|
-
const icon = String.fromCodePoint(i);
|
|
2186
|
-
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
2187
|
-
})] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
|
|
2188
|
-
return core$1.createVNode('div', {
|
|
2189
|
-
class: 'xnote-highlight-box-content'
|
|
2190
|
-
}, children);
|
|
2191
|
-
}, readonly())] }));
|
|
2576
|
+
return checkStates();
|
|
2192
2577
|
};
|
|
2193
2578
|
}
|
|
2194
|
-
const highlightBoxComponentLoader = {
|
|
2195
|
-
match(element) {
|
|
2196
|
-
return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
|
|
2197
|
-
},
|
|
2198
|
-
read(element, textbus, slotParser) {
|
|
2199
|
-
const delta = slotParser(new core$1.Slot([
|
|
2200
|
-
core$1.ContentType.BlockComponent,
|
|
2201
|
-
core$1.ContentType.InlineComponent,
|
|
2202
|
-
core$1.ContentType.Text
|
|
2203
|
-
]), element.querySelector('.xnote-highlight-box-content')).toDelta();
|
|
2204
|
-
const slot = new core$1.Slot([
|
|
2205
|
-
core$1.ContentType.BlockComponent,
|
|
2206
|
-
core$1.ContentType.InlineComponent,
|
|
2207
|
-
core$1.ContentType.Text
|
|
2208
|
-
]);
|
|
2209
|
-
deltaToBlock(delta, textbus).forEach(i => {
|
|
2210
|
-
slot.insert(i);
|
|
2211
|
-
});
|
|
2212
|
-
return new HighlightBoxComponent(textbus, {
|
|
2213
|
-
type: element.dataset.icon || '',
|
|
2214
|
-
slot
|
|
2215
|
-
});
|
|
2216
|
-
}
|
|
2217
|
-
};
|
|
2218
2579
|
|
|
2219
2580
|
function useBlockTransform() {
|
|
2220
2581
|
const commander = core.inject(core$1.Commander);
|
|
@@ -2236,124 +2597,74 @@ function useBlockTransform() {
|
|
|
2236
2597
|
commander.unApplyAttribute(headingAttr);
|
|
2237
2598
|
commander.transform({
|
|
2238
2599
|
targetType: ParagraphComponent.type,
|
|
2239
|
-
multipleSlot: false,
|
|
2240
2600
|
slotFactory() {
|
|
2241
2601
|
return new core$1.Slot([
|
|
2242
2602
|
core$1.ContentType.InlineComponent,
|
|
2243
2603
|
core$1.ContentType.Text
|
|
2244
2604
|
]);
|
|
2245
2605
|
},
|
|
2246
|
-
stateFactory(
|
|
2247
|
-
return new ParagraphComponent(textbus, {
|
|
2606
|
+
stateFactory(slots) {
|
|
2607
|
+
return slots.map(slot => new ParagraphComponent(textbus, {
|
|
2248
2608
|
slot
|
|
2249
|
-
});
|
|
2609
|
+
}));
|
|
2250
2610
|
}
|
|
2251
2611
|
});
|
|
2252
2612
|
break;
|
|
2253
2613
|
case 'table':
|
|
2254
2614
|
{
|
|
2255
2615
|
const table = new TableComponent(textbus);
|
|
2256
|
-
if (((_a = selection.commonAncestorSlot) === null || _a === void 0 ? void 0 : _a.isEmpty) && ((_b = selection.commonAncestorComponent) === null || _b === void 0 ? void 0 : _b.name) === ParagraphComponent.componentName) {
|
|
2257
|
-
commander.replaceComponent(selection.commonAncestorComponent, table);
|
|
2258
|
-
}
|
|
2259
|
-
else {
|
|
2260
|
-
commander.insert(table);
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
break;
|
|
2264
|
-
case 'todolist':
|
|
2265
|
-
commander.unApplyAttribute(headingAttr);
|
|
2266
|
-
commander.transform({
|
|
2267
|
-
targetType: TodolistComponent.type,
|
|
2268
|
-
multipleSlot: false,
|
|
2269
|
-
slotFactory() {
|
|
2270
|
-
return new core$1.Slot([
|
|
2271
|
-
core$1.ContentType.InlineComponent,
|
|
2272
|
-
core$1.ContentType.Text
|
|
2273
|
-
]);
|
|
2274
|
-
},
|
|
2275
|
-
stateFactory(slot) {
|
|
2276
|
-
return new TodolistComponent(textbus, {
|
|
2277
|
-
checked: false,
|
|
2278
|
-
slot
|
|
2279
|
-
});
|
|
2280
|
-
}
|
|
2281
|
-
});
|
|
2282
|
-
break;
|
|
2283
|
-
case 'ol':
|
|
2284
|
-
case 'ul':
|
|
2285
|
-
{
|
|
2286
|
-
commander.transform({
|
|
2287
|
-
targetType: ListComponent.type,
|
|
2288
|
-
multipleSlot: false,
|
|
2289
|
-
slotFactory() {
|
|
2290
|
-
return new core$1.Slot([
|
|
2291
|
-
core$1.ContentType.InlineComponent,
|
|
2292
|
-
core$1.ContentType.Text
|
|
2293
|
-
]);
|
|
2294
|
-
},
|
|
2295
|
-
stateFactory(slot) {
|
|
2296
|
-
return new ListComponent(textbus, {
|
|
2297
|
-
type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
|
|
2298
|
-
reorder: true,
|
|
2299
|
-
slot
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
});
|
|
2303
|
-
}
|
|
2304
|
-
break;
|
|
2305
|
-
case 'blockquote':
|
|
2306
|
-
{
|
|
2307
|
-
const state = query.queryComponent(BlockquoteComponent);
|
|
2308
|
-
if (state.state === core$1.QueryStateType.Enabled) {
|
|
2309
|
-
const current = state.value;
|
|
2310
|
-
const parent = current.parent;
|
|
2311
|
-
const index = parent.indexOf(current);
|
|
2312
|
-
parent.retain(index);
|
|
2313
|
-
commander.removeComponent(current);
|
|
2314
|
-
current.__slots__.get(0).sliceContent().forEach(i => {
|
|
2315
|
-
parent.insert(i);
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
else {
|
|
2319
|
-
const block = new BlockquoteComponent(textbus);
|
|
2320
|
-
const slot = block.state.slot;
|
|
2321
|
-
if (selection.startSlot === selection.endSlot) {
|
|
2322
|
-
const parentComponent = selection.startSlot.parent;
|
|
2323
|
-
const parentSlot = parentComponent.parent;
|
|
2324
|
-
const position = parentSlot.indexOf(parentComponent);
|
|
2325
|
-
slot.insert(parentComponent);
|
|
2326
|
-
parentSlot.retain(position);
|
|
2327
|
-
parentSlot.insert(block);
|
|
2328
|
-
}
|
|
2329
|
-
else {
|
|
2330
|
-
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2331
|
-
const scope = selection.getCommonAncestorSlotScope();
|
|
2332
|
-
commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
|
|
2333
|
-
slot.insert(i);
|
|
2334
|
-
});
|
|
2335
|
-
commonAncestorSlot.retain(scope.startOffset);
|
|
2336
|
-
commonAncestorSlot.insert(block);
|
|
2337
|
-
}
|
|
2616
|
+
if (((_a = selection.commonAncestorSlot) === null || _a === void 0 ? void 0 : _a.isEmpty) && ((_b = selection.commonAncestorComponent) === null || _b === void 0 ? void 0 : _b.name) === ParagraphComponent.componentName) {
|
|
2617
|
+
commander.replaceComponent(selection.commonAncestorComponent, table);
|
|
2618
|
+
}
|
|
2619
|
+
else {
|
|
2620
|
+
commander.insert(table);
|
|
2338
2621
|
}
|
|
2339
2622
|
}
|
|
2340
2623
|
break;
|
|
2624
|
+
case 'todolist':
|
|
2625
|
+
commander.unApplyAttribute(headingAttr);
|
|
2626
|
+
commander.transform({
|
|
2627
|
+
targetType: TodolistComponent.type,
|
|
2628
|
+
slotFactory() {
|
|
2629
|
+
return new core$1.Slot([
|
|
2630
|
+
core$1.ContentType.InlineComponent,
|
|
2631
|
+
core$1.ContentType.Text
|
|
2632
|
+
]);
|
|
2633
|
+
},
|
|
2634
|
+
stateFactory(slots) {
|
|
2635
|
+
return slots.map(slot => {
|
|
2636
|
+
return new TodolistComponent(textbus, {
|
|
2637
|
+
checked: false,
|
|
2638
|
+
slot
|
|
2639
|
+
});
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
});
|
|
2643
|
+
break;
|
|
2644
|
+
case 'ol':
|
|
2645
|
+
case 'ul':
|
|
2646
|
+
toList(textbus, value === 'ol' ? 'OrderedList' : 'UnorderedList');
|
|
2647
|
+
break;
|
|
2648
|
+
case 'blockquote':
|
|
2649
|
+
toBlockquote(textbus);
|
|
2650
|
+
break;
|
|
2341
2651
|
case 'sourceCode':
|
|
2342
2652
|
{
|
|
2343
2653
|
const state = query.queryComponent(SourceCodeComponent);
|
|
2344
2654
|
if (state.state === core$1.QueryStateType.Enabled) {
|
|
2345
2655
|
commander.transform({
|
|
2346
2656
|
targetType: ParagraphComponent.type,
|
|
2347
|
-
multipleSlot: false,
|
|
2348
2657
|
slotFactory() {
|
|
2349
2658
|
return new core$1.Slot([
|
|
2350
2659
|
core$1.ContentType.InlineComponent,
|
|
2351
2660
|
core$1.ContentType.Text
|
|
2352
2661
|
]);
|
|
2353
2662
|
},
|
|
2354
|
-
stateFactory(
|
|
2355
|
-
return
|
|
2356
|
-
|
|
2663
|
+
stateFactory(slots) {
|
|
2664
|
+
return slots.map(slot => {
|
|
2665
|
+
return new ParagraphComponent(textbus, {
|
|
2666
|
+
slot
|
|
2667
|
+
});
|
|
2357
2668
|
});
|
|
2358
2669
|
}
|
|
2359
2670
|
});
|
|
@@ -2361,24 +2672,25 @@ function useBlockTransform() {
|
|
|
2361
2672
|
else {
|
|
2362
2673
|
commander.transform({
|
|
2363
2674
|
targetType: SourceCodeComponent.type,
|
|
2364
|
-
multipleSlot: true,
|
|
2365
2675
|
slotFactory() {
|
|
2366
2676
|
return new core$1.Slot([
|
|
2367
2677
|
core$1.ContentType.Text
|
|
2368
2678
|
]);
|
|
2369
2679
|
},
|
|
2370
2680
|
stateFactory(slots) {
|
|
2371
|
-
return new SourceCodeComponent(textbus, {
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
slot
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2681
|
+
return [new SourceCodeComponent(textbus, {
|
|
2682
|
+
lang: '',
|
|
2683
|
+
lineNumber: true,
|
|
2684
|
+
autoBreak: true,
|
|
2685
|
+
slots: slots.map(slot => {
|
|
2686
|
+
slot.cleanFormats();
|
|
2687
|
+
slot.cleanAttributes();
|
|
2688
|
+
return {
|
|
2689
|
+
slot,
|
|
2690
|
+
emphasize: false
|
|
2691
|
+
};
|
|
2692
|
+
})
|
|
2693
|
+
})];
|
|
2382
2694
|
}
|
|
2383
2695
|
});
|
|
2384
2696
|
}
|
|
@@ -2393,7 +2705,7 @@ function useBlockTransform() {
|
|
|
2393
2705
|
const index = parent.indexOf(current);
|
|
2394
2706
|
parent.retain(index);
|
|
2395
2707
|
commander.removeComponent(current);
|
|
2396
|
-
current.
|
|
2708
|
+
current.slots.at(0).sliceContent().forEach(i => {
|
|
2397
2709
|
parent.insert(i);
|
|
2398
2710
|
});
|
|
2399
2711
|
}
|
|
@@ -2427,7 +2739,7 @@ function useBlockTransform() {
|
|
|
2427
2739
|
function BlockTool() {
|
|
2428
2740
|
const checkStates = useActiveBlock();
|
|
2429
2741
|
const transform = useBlockTransform();
|
|
2430
|
-
return scopedCss.withScopedCSS(
|
|
2742
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
2431
2743
|
const states = checkStates();
|
|
2432
2744
|
const types = [
|
|
2433
2745
|
[states.paragraph, 'xnote-icon-pilcrow'],
|
|
@@ -2442,7 +2754,7 @@ function BlockTool() {
|
|
|
2442
2754
|
[states.todolist, 'xnote-icon-checkbox-checked'],
|
|
2443
2755
|
[states.blockquote, 'xnote-icon-quotes-right'],
|
|
2444
2756
|
[states.sourceCode, 'xnote-icon-source-code'],
|
|
2445
|
-
[states.highlightBox, 'xnote-icon-
|
|
2757
|
+
[states.highlightBox, 'xnote-icon-highlight-box'],
|
|
2446
2758
|
];
|
|
2447
2759
|
let currentType = 'xnote-icon-pilcrow';
|
|
2448
2760
|
for (const t of types) {
|
|
@@ -2451,27 +2763,48 @@ function BlockTool() {
|
|
|
2451
2763
|
break;
|
|
2452
2764
|
}
|
|
2453
2765
|
}
|
|
2454
|
-
return (jsxRuntime.jsx(Dropdown, { onCheck: transform, trigger: 'hover', menu: [
|
|
2766
|
+
return (jsxRuntime.jsx(Dropdown, { width: 'auto', onCheck: transform, trigger: 'hover', menu: [
|
|
2455
2767
|
{
|
|
2456
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }),
|
|
2768
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2769
|
+
ctrlKey: true,
|
|
2770
|
+
key: '0'
|
|
2771
|
+
} }), checked: states.paragraph, children: "\u6B63\u6587" }),
|
|
2457
2772
|
value: 'paragraph'
|
|
2458
2773
|
}, {
|
|
2459
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }),
|
|
2774
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2775
|
+
ctrlKey: true,
|
|
2776
|
+
key: '1'
|
|
2777
|
+
} }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
|
|
2460
2778
|
value: 'h1'
|
|
2461
2779
|
}, {
|
|
2462
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }),
|
|
2780
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2781
|
+
ctrlKey: true,
|
|
2782
|
+
key: '2'
|
|
2783
|
+
} }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
|
|
2463
2784
|
value: 'h2'
|
|
2464
2785
|
}, {
|
|
2465
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }),
|
|
2786
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2787
|
+
ctrlKey: true,
|
|
2788
|
+
key: '3'
|
|
2789
|
+
} }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
|
|
2466
2790
|
value: 'h3'
|
|
2467
2791
|
}, {
|
|
2468
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }),
|
|
2792
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2793
|
+
ctrlKey: true,
|
|
2794
|
+
key: '4'
|
|
2795
|
+
} }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
|
|
2469
2796
|
value: 'h4'
|
|
2470
2797
|
}, {
|
|
2471
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }),
|
|
2798
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2799
|
+
ctrlKey: true,
|
|
2800
|
+
key: '5'
|
|
2801
|
+
} }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
|
|
2472
2802
|
value: 'h5'
|
|
2473
2803
|
}, {
|
|
2474
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }),
|
|
2804
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2805
|
+
ctrlKey: true,
|
|
2806
|
+
key: '6'
|
|
2807
|
+
} }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
|
|
2475
2808
|
value: 'h6'
|
|
2476
2809
|
}, {
|
|
2477
2810
|
label: jsxRuntime.jsx(Divider, {}),
|
|
@@ -2480,19 +2813,19 @@ function BlockTool() {
|
|
|
2480
2813
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), checked: states.todolist, children: "\u5F85\u529E\u4E8B\u9879" }),
|
|
2481
2814
|
value: 'todolist'
|
|
2482
2815
|
}, {
|
|
2483
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
|
|
2816
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'O', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
|
|
2484
2817
|
value: 'ol'
|
|
2485
2818
|
}, {
|
|
2486
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
|
|
2819
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'U', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
|
|
2487
2820
|
value: 'ul'
|
|
2488
2821
|
}, {
|
|
2489
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
|
|
2822
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '\'', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
|
|
2490
2823
|
value: 'blockquote'
|
|
2491
2824
|
}, {
|
|
2492
2825
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }), checked: states.sourceCode, children: "\u4EE3\u7801\u5757" }),
|
|
2493
2826
|
value: 'sourceCode'
|
|
2494
2827
|
}, {
|
|
2495
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-
|
|
2828
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), checked: states.highlightBox, children: "\u9AD8\u4EAE\u5757" }),
|
|
2496
2829
|
value: 'highlightBox'
|
|
2497
2830
|
}
|
|
2498
2831
|
], children: jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: currentType }) }) }));
|
|
@@ -2858,12 +3191,13 @@ function CodeTool() {
|
|
|
2858
3191
|
};
|
|
2859
3192
|
}
|
|
2860
3193
|
|
|
2861
|
-
var
|
|
3194
|
+
var scopedId$b = "vf-accb31";
|
|
2862
3195
|
|
|
2863
3196
|
function ColorTool(props) {
|
|
2864
3197
|
const query = core.inject(core$1.Query);
|
|
2865
3198
|
const refreshService = core.inject(exports.RefreshService);
|
|
2866
3199
|
const commander = core.inject(core$1.Commander);
|
|
3200
|
+
const selection = core.inject(core$1.Selection);
|
|
2867
3201
|
const textColor = core.createSignal('');
|
|
2868
3202
|
const backgroundColor = core.createSignal('');
|
|
2869
3203
|
const [viewModel] = hooks.useProduce({
|
|
@@ -2871,13 +3205,24 @@ function ColorTool(props) {
|
|
|
2871
3205
|
disabled: false,
|
|
2872
3206
|
});
|
|
2873
3207
|
function updateCheckState() {
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
const
|
|
3208
|
+
if (!props.slot && !selection.isSelected) {
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
const range = props.slot ? {
|
|
3212
|
+
startSlot: props.slot,
|
|
3213
|
+
endSlot: props.slot,
|
|
3214
|
+
startOffset: 0,
|
|
3215
|
+
endOffset: props.slot.length
|
|
3216
|
+
} : {
|
|
3217
|
+
startSlot: selection.startSlot,
|
|
3218
|
+
startOffset: selection.startOffset,
|
|
3219
|
+
endSlot: selection.endSlot,
|
|
3220
|
+
endOffset: selection.endOffset
|
|
3221
|
+
};
|
|
3222
|
+
const textState = query.queryFormatByRange(colorFormatter, range);
|
|
3223
|
+
const backgroundState = query.queryFormatByRange(backgroundColorFormatter, range);
|
|
2878
3224
|
textColor.set(textState.state === core$1.QueryStateType.Enabled ? textState.value : '');
|
|
2879
3225
|
backgroundColor.set(backgroundState.state === core$1.QueryStateType.Enabled ? backgroundState.value : '');
|
|
2880
|
-
(_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
2881
3226
|
}
|
|
2882
3227
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
2883
3228
|
updateCheckState();
|
|
@@ -2887,14 +3232,17 @@ function ColorTool(props) {
|
|
|
2887
3232
|
sub.unsubscribe();
|
|
2888
3233
|
});
|
|
2889
3234
|
const textColors = [
|
|
3235
|
+
'#000',
|
|
2890
3236
|
'#aaa',
|
|
2891
3237
|
'#ff2e2e',
|
|
2892
3238
|
'#ff8d45',
|
|
2893
3239
|
'#ffdf14',
|
|
2894
3240
|
'#5eec75',
|
|
2895
3241
|
'#5dfaff',
|
|
3242
|
+
'#1296db',
|
|
2896
3243
|
'#617fff',
|
|
2897
3244
|
'#c459ff',
|
|
3245
|
+
'#fff',
|
|
2898
3246
|
];
|
|
2899
3247
|
const backgroundColors = [
|
|
2900
3248
|
'#aaa',
|
|
@@ -2906,15 +3254,16 @@ function ColorTool(props) {
|
|
|
2906
3254
|
'#90a0e5',
|
|
2907
3255
|
'#c596e0',
|
|
2908
3256
|
];
|
|
2909
|
-
return scopedCss.withScopedCSS(
|
|
3257
|
+
return scopedCss.withScopedCSS(scopedId$b, () => {
|
|
2910
3258
|
const vm = viewModel();
|
|
2911
|
-
return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
3259
|
+
return (jsxRuntime.jsx(Dropdown, { style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
3260
|
+
'no-background': true,
|
|
2912
3261
|
active: textColor() === ''
|
|
2913
3262
|
}, onClick: () => {
|
|
2914
3263
|
var _a;
|
|
2915
3264
|
(_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
2916
3265
|
commander.unApplyFormat(colorFormatter);
|
|
2917
|
-
}
|
|
3266
|
+
} }), textColors.map(c => {
|
|
2918
3267
|
return jsxRuntime.jsx("div", { class: {
|
|
2919
3268
|
active: textColor() === c
|
|
2920
3269
|
}, onClick: () => {
|
|
@@ -2974,6 +3323,9 @@ const isSupportFont = (function () {
|
|
|
2974
3323
|
function FontFamilyTool() {
|
|
2975
3324
|
const currentFontFamily = core.createSignal('');
|
|
2976
3325
|
const fontFamilyOptions = [{
|
|
3326
|
+
label: '默认',
|
|
3327
|
+
value: ''
|
|
3328
|
+
}, {
|
|
2977
3329
|
label: '宋体',
|
|
2978
3330
|
value: 'SimSun, STSong'
|
|
2979
3331
|
}, {
|
|
@@ -3015,7 +3367,12 @@ function FontFamilyTool() {
|
|
|
3015
3367
|
}];
|
|
3016
3368
|
const commander = core.inject(core$1.Commander);
|
|
3017
3369
|
function check(v) {
|
|
3018
|
-
|
|
3370
|
+
if (v) {
|
|
3371
|
+
commander.applyFormat(fontFamilyFormatter, v);
|
|
3372
|
+
}
|
|
3373
|
+
else {
|
|
3374
|
+
commander.unApplyFormat(fontFamilyFormatter);
|
|
3375
|
+
}
|
|
3019
3376
|
}
|
|
3020
3377
|
const refreshService = core.inject(exports.RefreshService);
|
|
3021
3378
|
const query = core.inject(core$1.Query);
|
|
@@ -3024,7 +3381,7 @@ function FontFamilyTool() {
|
|
|
3024
3381
|
const result = query.queryFormat(fontFamilyFormatter);
|
|
3025
3382
|
const isHighlight = result.state === core$1.QueryStateType.Enabled;
|
|
3026
3383
|
highlight.set(isHighlight);
|
|
3027
|
-
currentFontFamily.set(isHighlight ? result.value : '
|
|
3384
|
+
currentFontFamily.set(isHighlight ? result.value : '');
|
|
3028
3385
|
});
|
|
3029
3386
|
core.onUnmounted(() => {
|
|
3030
3387
|
subscription.unsubscribe();
|
|
@@ -3032,7 +3389,7 @@ function FontFamilyTool() {
|
|
|
3032
3389
|
return () => {
|
|
3033
3390
|
var _a;
|
|
3034
3391
|
return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: fontFamilyOptions.map(i => {
|
|
3035
|
-
const disabled = !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v);
|
|
3392
|
+
const disabled = i.value ? !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v) : false;
|
|
3036
3393
|
return {
|
|
3037
3394
|
label: jsxRuntime.jsx(MenuItem, { disabled: disabled, checked: currentFontFamily() === i.value, children: i.label }),
|
|
3038
3395
|
disabled,
|
|
@@ -3064,7 +3421,12 @@ function FontSizeTool() {
|
|
|
3064
3421
|
];
|
|
3065
3422
|
const commander = core.inject(core$1.Commander);
|
|
3066
3423
|
function check(v) {
|
|
3067
|
-
|
|
3424
|
+
if (v) {
|
|
3425
|
+
commander.applyFormat(fontSizeFormatter, v);
|
|
3426
|
+
}
|
|
3427
|
+
else {
|
|
3428
|
+
commander.unApplyFormat(fontSizeFormatter);
|
|
3429
|
+
}
|
|
3068
3430
|
}
|
|
3069
3431
|
const refreshService = core.inject(exports.RefreshService);
|
|
3070
3432
|
const query = core.inject(core$1.Query);
|
|
@@ -3104,122 +3466,386 @@ function ItalicTool() {
|
|
|
3104
3466
|
update(draft => {
|
|
3105
3467
|
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3106
3468
|
});
|
|
3107
|
-
});
|
|
3108
|
-
core.onUnmounted(() => {
|
|
3109
|
-
sub.unsubscribe();
|
|
3110
|
-
});
|
|
3111
|
-
return () => {
|
|
3112
|
-
const vm = viewModel();
|
|
3113
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
3114
|
-
};
|
|
3115
|
-
}
|
|
3116
|
-
|
|
3117
|
-
var
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3469
|
+
});
|
|
3470
|
+
core.onUnmounted(() => {
|
|
3471
|
+
sub.unsubscribe();
|
|
3472
|
+
});
|
|
3473
|
+
return () => {
|
|
3474
|
+
const vm = viewModel();
|
|
3475
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
var scopedId$a = "vf-e74208";
|
|
3480
|
+
|
|
3481
|
+
exports.EditorService = class EditorService {
|
|
3482
|
+
constructor() {
|
|
3483
|
+
this.hideInlineToolbar = false;
|
|
3484
|
+
this.canShowLeftToolbar = true;
|
|
3485
|
+
this.onLeftToolbarCanVisibleChange = new core$1.Subject();
|
|
3486
|
+
}
|
|
3487
|
+
changeLeftToolbarVisible(b) {
|
|
3488
|
+
this.canShowLeftToolbar = b;
|
|
3489
|
+
this.onLeftToolbarCanVisibleChange.next();
|
|
3490
|
+
}
|
|
3491
|
+
};
|
|
3492
|
+
exports.EditorService = __decorate([
|
|
3493
|
+
core.Injectable({
|
|
3494
|
+
provideIn: 'root'
|
|
3495
|
+
})
|
|
3496
|
+
], exports.EditorService);
|
|
3497
|
+
|
|
3498
|
+
function LinkTool(props) {
|
|
3499
|
+
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
3500
|
+
const selection = core.inject(core$1.Selection);
|
|
3501
|
+
const commander = core.inject(core$1.Commander);
|
|
3502
|
+
const editorService = core.inject(exports.EditorService);
|
|
3503
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
3504
|
+
const isShow = core.createSignal(false);
|
|
3505
|
+
const inputRef = core.createRef();
|
|
3506
|
+
function setLink(ev) {
|
|
3507
|
+
ev.preventDefault();
|
|
3508
|
+
const value = inputRef.current.value;
|
|
3509
|
+
if (value) {
|
|
3510
|
+
commander.applyFormat(linkFormatter, {
|
|
3511
|
+
href: value,
|
|
3512
|
+
target: '_blanK'
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
isShow.set(false);
|
|
3516
|
+
}
|
|
3517
|
+
let isClickFromSelf = false;
|
|
3518
|
+
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
3519
|
+
if (isClickFromSelf) {
|
|
3520
|
+
isClickFromSelf = false;
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
editorService.hideInlineToolbar = false;
|
|
3524
|
+
isShow.set(false);
|
|
3525
|
+
});
|
|
3526
|
+
core.onUnmounted(() => {
|
|
3527
|
+
sub.unsubscribe();
|
|
3528
|
+
});
|
|
3529
|
+
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
3530
|
+
const containerRect = container.getBoundingClientRect();
|
|
3531
|
+
const rect = isShow() ? selectionBridge.getRect({
|
|
3532
|
+
slot: selection.focusSlot,
|
|
3533
|
+
offset: selection.focusOffset
|
|
3534
|
+
}) : {};
|
|
3535
|
+
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
3536
|
+
var _a;
|
|
3537
|
+
isShow.set(true);
|
|
3538
|
+
isClickFromSelf = true;
|
|
3539
|
+
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
3540
|
+
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
3541
|
+
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
3542
|
+
isClickFromSelf = true;
|
|
3543
|
+
}, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
function StrikeThroughTool() {
|
|
3548
|
+
const query = core.inject(core$1.Query);
|
|
3549
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
3550
|
+
const textbus = core.inject(core$1.Textbus);
|
|
3551
|
+
const [viewModel, update] = hooks.useProduce({
|
|
3552
|
+
highlight: false,
|
|
3553
|
+
disabled: false,
|
|
3554
|
+
});
|
|
3555
|
+
function toggle() {
|
|
3556
|
+
toggleStrikeThrough(textbus);
|
|
3557
|
+
}
|
|
3558
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
3559
|
+
const state = query.queryFormat(strikeThroughFormatter);
|
|
3560
|
+
update(draft => {
|
|
3561
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3562
|
+
});
|
|
3563
|
+
});
|
|
3564
|
+
core.onUnmounted(() => {
|
|
3565
|
+
sub.unsubscribe();
|
|
3566
|
+
});
|
|
3567
|
+
return () => {
|
|
3568
|
+
const vm = viewModel();
|
|
3569
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
3570
|
+
};
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
function UnderlineTool() {
|
|
3574
|
+
const query = core.inject(core$1.Query);
|
|
3575
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
3576
|
+
const textbus = core.inject(core$1.Textbus);
|
|
3577
|
+
const [viewModel, update] = hooks.useProduce({
|
|
3578
|
+
highlight: false,
|
|
3579
|
+
disabled: false,
|
|
3580
|
+
});
|
|
3581
|
+
function toggle() {
|
|
3582
|
+
toggleUnderline(textbus);
|
|
3583
|
+
}
|
|
3584
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
3585
|
+
const state = query.queryFormat(underlineFormatter);
|
|
3586
|
+
update(draft => {
|
|
3587
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3588
|
+
});
|
|
3589
|
+
});
|
|
3590
|
+
core.onUnmounted(() => {
|
|
3591
|
+
sub.unsubscribe();
|
|
3592
|
+
});
|
|
3593
|
+
return () => {
|
|
3594
|
+
const vm = viewModel();
|
|
3595
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
var scopedId$9 = "vf-cf8e1c";
|
|
3600
|
+
|
|
3601
|
+
class FileUploader {
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
class ImageComponent extends core$1.Component {
|
|
3605
|
+
static fromJSON(textbus, json) {
|
|
3606
|
+
return new ImageComponent(textbus, Object.assign({}, json));
|
|
3607
|
+
}
|
|
3608
|
+
getSlots() {
|
|
3609
|
+
return [];
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
3613
|
+
ImageComponent.componentName = 'ImageComponent';
|
|
3614
|
+
function ImageView(props) {
|
|
3615
|
+
const { name, state } = props.component;
|
|
3616
|
+
const imageRef = core.createRef();
|
|
3617
|
+
const readonly = useReadonly();
|
|
3618
|
+
const output = useOutput();
|
|
3619
|
+
return () => {
|
|
3620
|
+
if (readonly() || output()) {
|
|
3621
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
3622
|
+
width: state.width,
|
|
3623
|
+
height: state.height
|
|
3624
|
+
} }) }));
|
|
3625
|
+
}
|
|
3626
|
+
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: {
|
|
3627
|
+
width: state.width,
|
|
3628
|
+
height: state.height
|
|
3629
|
+
} }) }) }));
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
const imageComponentLoader = {
|
|
3633
|
+
match(element) {
|
|
3634
|
+
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
3635
|
+
},
|
|
3636
|
+
read(element, textbus) {
|
|
3637
|
+
const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
|
|
3638
|
+
return new ImageComponent(textbus, {
|
|
3639
|
+
src: img.src,
|
|
3640
|
+
width: img.style.width || 'auto',
|
|
3641
|
+
height: img.style.height || 'auto'
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3646
|
+
class VideoComponent extends core$1.Component {
|
|
3647
|
+
static fromJSON(textbus, json) {
|
|
3648
|
+
return new VideoComponent(textbus, Object.assign({}, json));
|
|
3649
|
+
}
|
|
3650
|
+
getSlots() {
|
|
3651
|
+
return [];
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
VideoComponent.type = core$1.ContentType.InlineComponent;
|
|
3655
|
+
VideoComponent.componentName = 'VideoComponent';
|
|
3656
|
+
function VideoView(props) {
|
|
3657
|
+
const { name, state } = props.component;
|
|
3658
|
+
const videoRef = core.createRef();
|
|
3659
|
+
const readonly = useReadonly();
|
|
3660
|
+
const output = useOutput();
|
|
3661
|
+
return () => {
|
|
3662
|
+
if (readonly() || output()) {
|
|
3663
|
+
return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
|
|
3664
|
+
width: state.width,
|
|
3665
|
+
height: state.height
|
|
3666
|
+
} }) }));
|
|
3667
|
+
}
|
|
3668
|
+
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: {
|
|
3669
|
+
width: state.width,
|
|
3670
|
+
height: state.height
|
|
3671
|
+
} }) }) }));
|
|
3672
|
+
};
|
|
3673
|
+
}
|
|
3674
|
+
const videoComponentLoader = {
|
|
3675
|
+
match(element) {
|
|
3676
|
+
return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
|
|
3677
|
+
},
|
|
3678
|
+
read(element, textbus) {
|
|
3679
|
+
const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
|
|
3680
|
+
return new VideoComponent(textbus, {
|
|
3681
|
+
src: video.src,
|
|
3682
|
+
width: video.style.width || 'auto',
|
|
3683
|
+
height: video.style.height || 'auto'
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
};
|
|
3687
|
+
|
|
3688
|
+
class KatexEditor extends core$1.Textbus {
|
|
3689
|
+
constructor() {
|
|
3690
|
+
const adapter = new adapterViewfly.ViewflyAdapter({
|
|
3691
|
+
[SourceCodeComponent.componentName]: SourceCodeView
|
|
3692
|
+
}, (host, root, injector) => {
|
|
3693
|
+
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
3694
|
+
provide: OutputInjectionToken,
|
|
3695
|
+
useValue: true
|
|
3696
|
+
}]);
|
|
3697
|
+
const app = platformBrowser$1.createApp(root, {
|
|
3698
|
+
context: appInjector
|
|
3699
|
+
}).mount(host);
|
|
3700
|
+
return () => {
|
|
3701
|
+
app.destroy();
|
|
3702
|
+
};
|
|
3703
|
+
});
|
|
3704
|
+
const browserModule = new platformBrowser.BrowserModule({
|
|
3705
|
+
adapter,
|
|
3706
|
+
renderTo: () => {
|
|
3707
|
+
return this.host;
|
|
3708
|
+
}
|
|
3709
|
+
});
|
|
3710
|
+
super({
|
|
3711
|
+
components: [
|
|
3712
|
+
SourceCodeComponent
|
|
3713
|
+
],
|
|
3714
|
+
imports: [browserModule]
|
|
3715
|
+
});
|
|
3716
|
+
this.onValueChange = new core$1.Subject();
|
|
3717
|
+
}
|
|
3718
|
+
mount(host, code) {
|
|
3719
|
+
this.host = host;
|
|
3720
|
+
const model = new SourceCodeComponent(this, {
|
|
3721
|
+
lineNumber: true,
|
|
3722
|
+
autoBreak: true,
|
|
3723
|
+
lang: 'latex',
|
|
3724
|
+
theme: 'github',
|
|
3725
|
+
slots: code.split('\n').map(i => {
|
|
3726
|
+
const slot = new core$1.Slot([core$1.ContentType.Text]);
|
|
3727
|
+
slot.insert(i);
|
|
3728
|
+
return {
|
|
3729
|
+
slot,
|
|
3730
|
+
emphasize: false
|
|
3731
|
+
};
|
|
3732
|
+
})
|
|
3733
|
+
});
|
|
3734
|
+
this.onChange.subscribe(() => {
|
|
3735
|
+
const str = model.state.slots.map(i => {
|
|
3736
|
+
if (i.slot.isEmpty) {
|
|
3737
|
+
return '';
|
|
3738
|
+
}
|
|
3739
|
+
return i.slot.toString();
|
|
3740
|
+
}).join('\n');
|
|
3741
|
+
this.onValueChange.next(str);
|
|
3742
|
+
});
|
|
3743
|
+
return this.render(model);
|
|
3136
3744
|
}
|
|
3137
|
-
let isClickFromSelf = false;
|
|
3138
|
-
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
3139
|
-
if (isClickFromSelf) {
|
|
3140
|
-
isClickFromSelf = false;
|
|
3141
|
-
return;
|
|
3142
|
-
}
|
|
3143
|
-
isShow.set(false);
|
|
3144
|
-
});
|
|
3145
|
-
core.onUnmounted(() => {
|
|
3146
|
-
sub.unsubscribe();
|
|
3147
|
-
});
|
|
3148
|
-
return scopedCss.withScopedCSS(css$9, () => {
|
|
3149
|
-
const containerRect = container.getBoundingClientRect();
|
|
3150
|
-
const rect = isShow() ? selectionBridge.getRect({
|
|
3151
|
-
slot: selection.focusSlot,
|
|
3152
|
-
offset: selection.focusOffset
|
|
3153
|
-
}) : {};
|
|
3154
|
-
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
3155
|
-
isShow.set(true);
|
|
3156
|
-
isClickFromSelf = true;
|
|
3157
|
-
setTimeout(() => { var _a; return (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props); }, 10);
|
|
3158
|
-
}, arrow: true, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
3159
|
-
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
3160
|
-
isClickFromSelf = true;
|
|
3161
|
-
}, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
3162
|
-
});
|
|
3163
3745
|
}
|
|
3164
3746
|
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
const textbus = core.inject(core$1.Textbus);
|
|
3169
|
-
const [viewModel, update] = hooks.useProduce({
|
|
3170
|
-
highlight: false,
|
|
3171
|
-
disabled: false,
|
|
3172
|
-
});
|
|
3173
|
-
function toggle() {
|
|
3174
|
-
toggleStrikeThrough(textbus);
|
|
3747
|
+
class KatexComponent extends core$1.Component {
|
|
3748
|
+
static fromJSON(textbus, state) {
|
|
3749
|
+
return new KatexComponent(textbus, state);
|
|
3175
3750
|
}
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3751
|
+
constructor(textbus, state = {
|
|
3752
|
+
text: '% \\f is defined as #1f(#2) using the macro\n' +
|
|
3753
|
+
'\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
|
|
3754
|
+
'\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
|
|
3755
|
+
'\\,d\\xi'
|
|
3756
|
+
}) {
|
|
3757
|
+
super(textbus, state);
|
|
3758
|
+
}
|
|
3759
|
+
getSlots() {
|
|
3760
|
+
return [];
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
KatexComponent.componentName = 'KatexComponent';
|
|
3764
|
+
KatexComponent.type = core$1.ContentType.InlineComponent;
|
|
3765
|
+
function domToVDom(el) {
|
|
3766
|
+
const attrs = {};
|
|
3767
|
+
el.getAttributeNames().forEach(key => {
|
|
3768
|
+
attrs[key] = el.getAttribute(key);
|
|
3181
3769
|
});
|
|
3182
|
-
|
|
3183
|
-
|
|
3770
|
+
attrs.children = Array.from(el.childNodes).map(child => {
|
|
3771
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
3772
|
+
return domToVDom(child);
|
|
3773
|
+
}
|
|
3774
|
+
return child.textContent || '';
|
|
3184
3775
|
});
|
|
3185
|
-
return ()
|
|
3186
|
-
const vm = viewModel();
|
|
3187
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
3188
|
-
};
|
|
3776
|
+
return core.jsx(el.tagName.toLowerCase(), attrs);
|
|
3189
3777
|
}
|
|
3190
|
-
|
|
3191
|
-
function
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3778
|
+
function KatexComponentView(props) {
|
|
3779
|
+
function toDOM(value) {
|
|
3780
|
+
let htmlString;
|
|
3781
|
+
try {
|
|
3782
|
+
htmlString = Katex.renderToString(value, {
|
|
3783
|
+
displayMode: true,
|
|
3784
|
+
leqno: false,
|
|
3785
|
+
fleqn: false,
|
|
3786
|
+
throwOnError: true,
|
|
3787
|
+
errorColor: '#cc0000',
|
|
3788
|
+
strict: 'warn',
|
|
3789
|
+
output: 'html',
|
|
3790
|
+
trust: false,
|
|
3791
|
+
macros: { '\\f': '#1f(#2)' }
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
catch (e) {
|
|
3795
|
+
htmlString = '<span style="color: red">公式错误</span>';
|
|
3796
|
+
}
|
|
3797
|
+
return new DOMParser().parseFromString(htmlString, 'text/html').body.children[0];
|
|
3201
3798
|
}
|
|
3202
|
-
const
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3799
|
+
const selection = core.inject(core$1.Textbus);
|
|
3800
|
+
const editorRef = core.createDynamicRef(node => {
|
|
3801
|
+
const editor = new KatexEditor();
|
|
3802
|
+
editor.mount(node, props.component.state.text).then(() => {
|
|
3803
|
+
editor.focus();
|
|
3206
3804
|
});
|
|
3805
|
+
selection.blur();
|
|
3806
|
+
const subscription = editor.onValueChange.subscribe((value) => {
|
|
3807
|
+
props.component.state.text = value;
|
|
3808
|
+
}).add(core$1.fromEvent(node, 'mousedown').subscribe(ev => ev.stopPropagation()), core$1.fromEvent(document, 'mousedown').subscribe(() => {
|
|
3809
|
+
var _a;
|
|
3810
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
3811
|
+
}));
|
|
3812
|
+
return () => {
|
|
3813
|
+
subscription.unsubscribe();
|
|
3814
|
+
editor.destroy();
|
|
3815
|
+
};
|
|
3207
3816
|
});
|
|
3208
|
-
core.
|
|
3209
|
-
|
|
3210
|
-
|
|
3817
|
+
const dropdownRef = core.createRef();
|
|
3818
|
+
const output = useOutput();
|
|
3819
|
+
const readonly = useReadonly();
|
|
3211
3820
|
return () => {
|
|
3212
|
-
const
|
|
3213
|
-
return
|
|
3821
|
+
const text = props.component.state.text;
|
|
3822
|
+
return (jsxRuntime.jsx("span", { onClick: () => {
|
|
3823
|
+
var _a;
|
|
3824
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(true);
|
|
3825
|
+
}, ref: props.rootRef, "data-component": KatexComponent.componentName, "data-katex": encodeURIComponent(text), class: "xnote-katex", children: (output() || readonly()) ?
|
|
3826
|
+
domToVDom(toDOM(text))
|
|
3827
|
+
:
|
|
3828
|
+
jsxRuntime.jsx(Dropdown, { padding: '0', ref: dropdownRef, trigger: 'none', width: '600px', menu: jsxRuntime.jsx("div", { class: "xnote-katex-input", ref: editorRef }), children: domToVDom(toDOM(text)) }) }));
|
|
3214
3829
|
};
|
|
3215
3830
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3831
|
+
const katexComponentLoader = {
|
|
3832
|
+
match(element) {
|
|
3833
|
+
return element.dataset.component === KatexComponent.componentName;
|
|
3834
|
+
},
|
|
3835
|
+
read(element, textbus) {
|
|
3836
|
+
const value = element.dataset.katex || '';
|
|
3837
|
+
return new KatexComponent(textbus, {
|
|
3838
|
+
text: decodeURIComponent(value)
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
};
|
|
3218
3842
|
|
|
3219
3843
|
function InsertTool(props) {
|
|
3220
3844
|
const commander = core.inject(core$1.Commander);
|
|
3221
3845
|
const selection = core.inject(core$1.Selection);
|
|
3222
3846
|
const textbus = core.inject(core$1.Textbus);
|
|
3847
|
+
const fileUploader = core.inject(FileUploader, null);
|
|
3848
|
+
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
3223
3849
|
function insert(type) {
|
|
3224
3850
|
var _a;
|
|
3225
3851
|
const component = (_a = props.slot) === null || _a === void 0 ? void 0 : _a.parent;
|
|
@@ -3233,6 +3859,8 @@ function InsertTool(props) {
|
|
|
3233
3859
|
else {
|
|
3234
3860
|
commander.insertAfter(comp, component);
|
|
3235
3861
|
}
|
|
3862
|
+
dropdownContextService.canHide = true;
|
|
3863
|
+
dropdownContextService.hide(false);
|
|
3236
3864
|
}
|
|
3237
3865
|
switch (type) {
|
|
3238
3866
|
case 'h1':
|
|
@@ -3294,7 +3922,9 @@ function InsertTool(props) {
|
|
|
3294
3922
|
{
|
|
3295
3923
|
const table = new TableComponent(textbus);
|
|
3296
3924
|
insertComponent(table);
|
|
3297
|
-
|
|
3925
|
+
textbus.nextTick(() => {
|
|
3926
|
+
selection.selectFirstPosition(table, true, true);
|
|
3927
|
+
});
|
|
3298
3928
|
}
|
|
3299
3929
|
break;
|
|
3300
3930
|
case 'todolist':
|
|
@@ -3312,8 +3942,24 @@ function InsertTool(props) {
|
|
|
3312
3942
|
}
|
|
3313
3943
|
break;
|
|
3314
3944
|
case 'image':
|
|
3945
|
+
if (fileUploader) {
|
|
3946
|
+
Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
|
|
3947
|
+
const img = new ImageComponent(textbus, {
|
|
3948
|
+
src: url
|
|
3949
|
+
});
|
|
3950
|
+
commander.insert(img);
|
|
3951
|
+
});
|
|
3952
|
+
}
|
|
3315
3953
|
break;
|
|
3316
3954
|
case 'video':
|
|
3955
|
+
if (fileUploader) {
|
|
3956
|
+
Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
|
|
3957
|
+
const img = new VideoComponent(textbus, {
|
|
3958
|
+
src: url
|
|
3959
|
+
});
|
|
3960
|
+
commander.insert(img);
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3317
3963
|
break;
|
|
3318
3964
|
case 'highlightBox':
|
|
3319
3965
|
{
|
|
@@ -3324,14 +3970,23 @@ function InsertTool(props) {
|
|
|
3324
3970
|
selection.setPosition(p.state.slot, 0);
|
|
3325
3971
|
}
|
|
3326
3972
|
break;
|
|
3973
|
+
case 'katex':
|
|
3974
|
+
{
|
|
3975
|
+
const p = new ParagraphComponent(textbus);
|
|
3976
|
+
const comp = new KatexComponent(textbus);
|
|
3977
|
+
p.state.slot.insert(comp);
|
|
3978
|
+
insertComponent(p);
|
|
3979
|
+
selection.selectComponent(comp);
|
|
3980
|
+
}
|
|
3981
|
+
break;
|
|
3327
3982
|
}
|
|
3328
3983
|
}
|
|
3329
|
-
return scopedCss.withScopedCSS(
|
|
3330
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: () => insert('table'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('image'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('video'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-
|
|
3984
|
+
return scopedCss.withScopedCSS(scopedId$9, () => {
|
|
3985
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.hideTitle ? null : jsxRuntime.jsx(MenuHeading, { children: props.replace ? '替换为' : '在下面添加' }), jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: () => insert('table'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('image'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('video'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), children: "\u9AD8\u4EAE\u5757" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('katex'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-function" }), children: "\u6570\u5B66\u516C\u5F0F" })] });
|
|
3331
3986
|
});
|
|
3332
3987
|
}
|
|
3333
3988
|
|
|
3334
|
-
var
|
|
3989
|
+
var scopedId$8 = "vf-b05292";
|
|
3335
3990
|
|
|
3336
3991
|
const LeftToolbar = core.withAnnotation({
|
|
3337
3992
|
providers: [exports.RefreshService]
|
|
@@ -3341,6 +3996,7 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3341
3996
|
const selection = core.inject(core$1.Selection);
|
|
3342
3997
|
const rootComponentRef = core.inject(core$1.RootComponentRef);
|
|
3343
3998
|
const refreshService = core.inject(exports.RefreshService);
|
|
3999
|
+
const editorService = core.inject(exports.EditorService);
|
|
3344
4000
|
const checkStates = useActiveBlock();
|
|
3345
4001
|
const toBlock = useBlockTransform();
|
|
3346
4002
|
const activeSlot = core.createSignal(null);
|
|
@@ -3359,6 +4015,14 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3359
4015
|
top: 0,
|
|
3360
4016
|
display: false
|
|
3361
4017
|
});
|
|
4018
|
+
const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
|
|
4019
|
+
updatePosition(d => {
|
|
4020
|
+
d.display = editorService.canShowLeftToolbar;
|
|
4021
|
+
});
|
|
4022
|
+
});
|
|
4023
|
+
core.onUnmounted(() => {
|
|
4024
|
+
sub.unsubscribe();
|
|
4025
|
+
});
|
|
3362
4026
|
let isIgnoreMove = false;
|
|
3363
4027
|
core.onMounted(() => {
|
|
3364
4028
|
const rootComponent = rootComponentRef.component;
|
|
@@ -3366,12 +4030,14 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3366
4030
|
const sub = core$1.fromEvent(docContentContainer, 'mousemove').pipe(core$1.filter(() => {
|
|
3367
4031
|
return !isIgnoreMove;
|
|
3368
4032
|
}), core$1.map(ev => {
|
|
4033
|
+
var _a;
|
|
3369
4034
|
let currentNode = ev.target;
|
|
3370
4035
|
while (currentNode) {
|
|
3371
4036
|
const slot = adapter.getSlotByNativeNode(currentNode);
|
|
3372
4037
|
if (slot) {
|
|
3373
|
-
if ((slot === null || slot === void 0 ? void 0 : slot.parent)
|
|
3374
|
-
|
|
4038
|
+
if (((_a = slot === null || slot === void 0 ? void 0 : slot.parent) === null || _a === void 0 ? void 0 : _a.type) === core$1.ContentType.InlineComponent) {
|
|
4039
|
+
currentNode = currentNode.parentNode;
|
|
4040
|
+
continue;
|
|
3375
4041
|
}
|
|
3376
4042
|
return slot;
|
|
3377
4043
|
}
|
|
@@ -3386,7 +4052,9 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3386
4052
|
activeSlot.set(slot);
|
|
3387
4053
|
if (slot) {
|
|
3388
4054
|
checkStates(slot);
|
|
3389
|
-
isEmptyBlock.set(slot.parent instanceof ParagraphComponent && slot.isEmpty)
|
|
4055
|
+
isEmptyBlock.set((slot.parent instanceof ParagraphComponent && slot.isEmpty) ||
|
|
4056
|
+
slot.parent instanceof SourceCodeComponent ||
|
|
4057
|
+
slot.parent instanceof TableComponent);
|
|
3390
4058
|
const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
|
|
3391
4059
|
updatePosition(draft => {
|
|
3392
4060
|
const containerRect = docContentContainer.getBoundingClientRect();
|
|
@@ -3439,18 +4107,6 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3439
4107
|
isShow.set(true);
|
|
3440
4108
|
}));
|
|
3441
4109
|
});
|
|
3442
|
-
let snapshot = null;
|
|
3443
|
-
function queryBefore() {
|
|
3444
|
-
const slot = activeSlot();
|
|
3445
|
-
if (slot) {
|
|
3446
|
-
snapshot = selection.createSnapshot();
|
|
3447
|
-
selection.selectSlot(slot);
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
function queryAfter() {
|
|
3451
|
-
snapshot === null || snapshot === void 0 ? void 0 : snapshot.restore();
|
|
3452
|
-
snapshot = null;
|
|
3453
|
-
}
|
|
3454
4110
|
function applyBefore() {
|
|
3455
4111
|
const slot = activeSlot();
|
|
3456
4112
|
if (slot) {
|
|
@@ -3482,7 +4138,7 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3482
4138
|
if (!slot) {
|
|
3483
4139
|
return;
|
|
3484
4140
|
}
|
|
3485
|
-
if (slot.parent.
|
|
4141
|
+
if (slot.parent.slots.length <= 1) {
|
|
3486
4142
|
commander.removeComponent(slot.parent);
|
|
3487
4143
|
}
|
|
3488
4144
|
else {
|
|
@@ -3494,20 +4150,21 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3494
4150
|
function changeIgnoreMove(b) {
|
|
3495
4151
|
isIgnoreMove = b;
|
|
3496
4152
|
}
|
|
3497
|
-
return scopedCss.withScopedCSS(
|
|
4153
|
+
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
4154
|
+
var _a;
|
|
3498
4155
|
const position = positionSignal();
|
|
3499
4156
|
const slot = activeSlot();
|
|
3500
4157
|
let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
|
|
3501
|
-
const states = checkStates();
|
|
4158
|
+
const states = checkStates(slot);
|
|
3502
4159
|
if (slot) {
|
|
3503
4160
|
const types = [
|
|
3504
4161
|
[states.paragraph, jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" })],
|
|
3505
4162
|
[states.sourceCode, jsxRuntime.jsx("span", { class: "xnote-icon-source-code" })],
|
|
3506
4163
|
[states.blockquote, jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" })],
|
|
3507
4164
|
[states.todolist, jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" })],
|
|
3508
|
-
[states.table, jsxRuntime.jsx("span", { class: "xnote-icon-table" })],
|
|
3509
4165
|
[states.unorderedList, jsxRuntime.jsx("span", { class: "xnote-icon-list" })],
|
|
3510
4166
|
[states.orderedList, jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" })],
|
|
4167
|
+
[states.table, jsxRuntime.jsx("span", { class: "xnote-icon-table" })],
|
|
3511
4168
|
[states.h1, jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" })],
|
|
3512
4169
|
[states.h2, jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" })],
|
|
3513
4170
|
[states.h3, jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" })],
|
|
@@ -3522,18 +4179,20 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3522
4179
|
}
|
|
3523
4180
|
}
|
|
3524
4181
|
}
|
|
4182
|
+
const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
|
|
4183
|
+
const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
|
|
3525
4184
|
return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
|
|
3526
4185
|
left: position.left + 'px',
|
|
3527
4186
|
top: position.top + 'px',
|
|
3528
|
-
display: position.display && selection.isCollapsed ? 'block' : 'none'
|
|
3529
|
-
}, children: jsxRuntime.jsx(Dropdown, { onExpendStateChange: changeIgnoreMove, abreast: true, style: {
|
|
4187
|
+
display: position.display && selection.isCollapsed && editorService.canShowLeftToolbar ? 'block' : 'none'
|
|
4188
|
+
}, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
|
|
3530
4189
|
position: 'absolute',
|
|
3531
4190
|
right: 0,
|
|
3532
4191
|
top: 0
|
|
3533
4192
|
}, menu: isEmptyBlock() ?
|
|
3534
|
-
jsxRuntime.jsx(InsertTool, { replace:
|
|
4193
|
+
jsxRuntime.jsx(InsertTool, { replace: !needInsert, slot: activeSlot() })
|
|
3535
4194
|
:
|
|
3536
|
-
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(AttrTool, { style: { display: 'block' }, abreast: true,
|
|
4195
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsxRuntime.jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: copy, icon: jsxRuntime.jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsxRuntime.jsx(MenuItem, { onClick: remove, icon: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsxRuntime.jsx(MenuItem, { onClick: cut, icon: jsxRuntime.jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsxRuntime.jsx(InsertTool, { hideTitle: true, slot: activeSlot() }), children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsxRuntime.jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
|
|
3537
4196
|
jsxRuntime.jsx("span", { children: jsxRuntime.jsx("i", { class: "xnote-icon-plus" }) })
|
|
3538
4197
|
:
|
|
3539
4198
|
jsxRuntime.jsxs("span", { children: [activeNode, jsxRuntime.jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
|
|
@@ -3568,24 +4227,74 @@ class LeftToolbarPlugin {
|
|
|
3568
4227
|
}
|
|
3569
4228
|
}
|
|
3570
4229
|
|
|
3571
|
-
var
|
|
4230
|
+
var scopedId$7 = "vf-3073ba";
|
|
3572
4231
|
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
4232
|
+
function LinkJump() {
|
|
4233
|
+
const selection = core.inject(core$1.Selection);
|
|
4234
|
+
const query = core.inject(core$1.Query);
|
|
4235
|
+
const bridge = core.inject(platformBrowser.SelectionBridge);
|
|
4236
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4237
|
+
const href = core.createSignal('');
|
|
4238
|
+
const ref = core.createRef();
|
|
4239
|
+
const isShow = core.createSignal(false);
|
|
4240
|
+
function onSelectionChange() {
|
|
4241
|
+
if (selection.isCollapsed) {
|
|
4242
|
+
const queryState = query.queryFormat(linkFormatter);
|
|
4243
|
+
if (queryState.state === core$1.QueryStateType.Enabled) {
|
|
4244
|
+
const rect = bridge.getRect({
|
|
4245
|
+
slot: selection.startSlot,
|
|
4246
|
+
offset: selection.startOffset
|
|
4247
|
+
});
|
|
4248
|
+
if (rect) {
|
|
4249
|
+
const offsetRect = container.getBoundingClientRect();
|
|
4250
|
+
Object.assign(ref.current.style, {
|
|
4251
|
+
left: rect.left - offsetRect.left + 'px',
|
|
4252
|
+
top: rect.top - offsetRect.top + 'px'
|
|
4253
|
+
});
|
|
4254
|
+
isShow.set(true);
|
|
4255
|
+
let url = queryState.value.href;
|
|
4256
|
+
if (url.indexOf('://') < 0) {
|
|
4257
|
+
url = 'http://' + url;
|
|
4258
|
+
}
|
|
4259
|
+
href.set(url);
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
isShow.set(false);
|
|
3576
4265
|
}
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
4266
|
+
selection.onChange.pipe(core$1.delay()).subscribe(() => {
|
|
4267
|
+
onSelectionChange();
|
|
4268
|
+
});
|
|
4269
|
+
function cleanLink() {
|
|
4270
|
+
isShow.set(false);
|
|
4271
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
4272
|
+
const index = selection.focusOffset;
|
|
4273
|
+
const ranges = commonAncestorSlot.getFormatRangesByFormatter(linkFormatter, 0, commonAncestorSlot.length);
|
|
4274
|
+
ranges.forEach(range => {
|
|
4275
|
+
if (range.startIndex < index && range.endIndex >= index) {
|
|
4276
|
+
commonAncestorSlot.applyFormat(linkFormatter, {
|
|
4277
|
+
startIndex: range.startIndex,
|
|
4278
|
+
endIndex: range.endIndex,
|
|
4279
|
+
value: null
|
|
4280
|
+
});
|
|
4281
|
+
}
|
|
4282
|
+
});
|
|
4283
|
+
}
|
|
4284
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$7, () => {
|
|
4285
|
+
return (jsxRuntime.jsxs("div", { ref: ref, class: "link-jump-plugin", style: { display: isShow() ? '' : 'none' }, children: [jsxRuntime.jsx("span", { onClick: cleanLink, children: "\u6E05\u9664" }), jsxRuntime.jsx("a", { target: "_blank", href: href(), children: "\u8DF3\u8F6C" })] }));
|
|
4286
|
+
}), container);
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4289
|
+
var scopedId$6 = "vf-fee98b";
|
|
3583
4290
|
|
|
3584
4291
|
const Toolbar = core.withAnnotation({
|
|
3585
4292
|
providers: [exports.RefreshService]
|
|
3586
4293
|
}, function Toolbar() {
|
|
3587
4294
|
const selection = core.inject(core$1.Selection);
|
|
3588
4295
|
const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4296
|
+
const rootComponentRef = core.inject(core$1.RootComponentRef);
|
|
4297
|
+
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
3589
4298
|
const bridge = core.inject(platformBrowser.SelectionBridge);
|
|
3590
4299
|
const textbus = core.inject(core$1.Textbus);
|
|
3591
4300
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -3607,7 +4316,7 @@ const Toolbar = core.withAnnotation({
|
|
|
3607
4316
|
const toolbarRef = core.createRef();
|
|
3608
4317
|
function getTop() {
|
|
3609
4318
|
const docRect = viewDocument.getBoundingClientRect();
|
|
3610
|
-
const
|
|
4319
|
+
const toolbarHeight = 36;
|
|
3611
4320
|
// const documentHeight = document.documentElement.clientHeight
|
|
3612
4321
|
const selectionFocusRect = bridge.getRect({
|
|
3613
4322
|
slot: selection.focusSlot,
|
|
@@ -3616,14 +4325,12 @@ const Toolbar = core.withAnnotation({
|
|
|
3616
4325
|
if (!selectionFocusRect) {
|
|
3617
4326
|
return null;
|
|
3618
4327
|
}
|
|
3619
|
-
// console.log(selectionFocusRect.top, toolbarRect.height)
|
|
3620
4328
|
const centerLeft = selectionFocusRect.left;
|
|
3621
|
-
const toBottom = selectionFocusRect.top <
|
|
4329
|
+
const toBottom = selectionFocusRect.top < toolbarHeight + 10;
|
|
3622
4330
|
const top = toBottom ?
|
|
3623
4331
|
selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
|
|
3624
|
-
selectionFocusRect.top - docRect.top -
|
|
4332
|
+
selectionFocusRect.top - docRect.top - toolbarHeight - 10;
|
|
3625
4333
|
updateViewPosition(draft => {
|
|
3626
|
-
draft.isHide = false;
|
|
3627
4334
|
draft.transitionDuration = .15;
|
|
3628
4335
|
draft.left = centerLeft - docRect.left;
|
|
3629
4336
|
draft.top = top + 10;
|
|
@@ -3644,13 +4351,15 @@ const Toolbar = core.withAnnotation({
|
|
|
3644
4351
|
sub.unsubscribe();
|
|
3645
4352
|
});
|
|
3646
4353
|
function bindMouseup() {
|
|
3647
|
-
|
|
4354
|
+
const docElement = adapter.getNativeNodeByComponent(rootComponentRef.component);
|
|
4355
|
+
mouseupSubscription = core$1.fromEvent(docElement, 'mouseup').pipe(core$1.filter(ev => {
|
|
3648
4356
|
return !ev.composedPath().includes(toolbarRef.current);
|
|
3649
4357
|
}), core$1.delay(100), core$1.filter(() => {
|
|
3650
4358
|
return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
|
|
3651
4359
|
}), core$1.map(getTop), core$1.delay(200)).subscribe((top) => {
|
|
3652
4360
|
if (top !== null) {
|
|
3653
4361
|
updateViewPosition(draft => {
|
|
4362
|
+
draft.isHide = false;
|
|
3654
4363
|
draft.opacity = 1;
|
|
3655
4364
|
draft.top = top;
|
|
3656
4365
|
});
|
|
@@ -3669,16 +4378,16 @@ const Toolbar = core.withAnnotation({
|
|
|
3669
4378
|
});
|
|
3670
4379
|
bindMouseup();
|
|
3671
4380
|
});
|
|
4381
|
+
const instance = core.getCurrentInstance();
|
|
3672
4382
|
function hideToolbar() {
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
});
|
|
4383
|
+
editorService.hideInlineToolbar = true;
|
|
4384
|
+
instance.markAsDirtied();
|
|
3676
4385
|
}
|
|
3677
4386
|
core.onUnmounted(() => {
|
|
3678
4387
|
mousedownSubscription.unsubscribe();
|
|
3679
4388
|
mouseupSubscription.unsubscribe();
|
|
3680
4389
|
});
|
|
3681
|
-
return scopedCss.withScopedCSS(
|
|
4390
|
+
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
3682
4391
|
const p = viewPosition();
|
|
3683
4392
|
return (jsxRuntime.jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
|
|
3684
4393
|
left: p.left + 'px',
|
|
@@ -3807,45 +4516,224 @@ class Matcher {
|
|
|
3807
4516
|
return v === styleValue;
|
|
3808
4517
|
}).includes(true);
|
|
3809
4518
|
}
|
|
3810
|
-
return false;
|
|
3811
|
-
}).includes(false);
|
|
3812
|
-
};
|
|
4519
|
+
return false;
|
|
4520
|
+
}).includes(false);
|
|
4521
|
+
};
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
class Organization {
|
|
4526
|
+
}
|
|
4527
|
+
function registerAtShortcut(textbus) {
|
|
4528
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
4529
|
+
const selection = textbus.get(core$1.Selection);
|
|
4530
|
+
const commander = textbus.get(core$1.Commander);
|
|
4531
|
+
keyboard.addShortcut({
|
|
4532
|
+
keymap: {
|
|
4533
|
+
key: '@',
|
|
4534
|
+
shiftKey: true
|
|
4535
|
+
},
|
|
4536
|
+
action() {
|
|
4537
|
+
const { commonAncestorComponent } = selection;
|
|
4538
|
+
if (commonAncestorComponent instanceof SourceCodeComponent) {
|
|
4539
|
+
return false;
|
|
4540
|
+
}
|
|
4541
|
+
const at = new AtComponent(textbus);
|
|
4542
|
+
commander.insert(at);
|
|
4543
|
+
selection.setPosition(at.state.slot, 0);
|
|
4544
|
+
}
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4547
|
+
class AtComponent extends core$1.Component {
|
|
4548
|
+
static fromJSON(textbus, { slot: slotState, userInfo }) {
|
|
4549
|
+
const registry = textbus.get(core$1.Registry);
|
|
4550
|
+
if (slotState) {
|
|
4551
|
+
const slot = registry.createSlot(slotState);
|
|
4552
|
+
return new AtComponent(textbus, {
|
|
4553
|
+
slot
|
|
4554
|
+
});
|
|
4555
|
+
}
|
|
4556
|
+
return new AtComponent(textbus, {
|
|
4557
|
+
userInfo,
|
|
4558
|
+
});
|
|
4559
|
+
}
|
|
4560
|
+
constructor(textbus, state = {
|
|
4561
|
+
slot: new core$1.Slot([core$1.ContentType.Text])
|
|
4562
|
+
}) {
|
|
4563
|
+
if (!state.userInfo && !state.slot) {
|
|
4564
|
+
state.slot = new core$1.Slot([core$1.ContentType.Text]);
|
|
4565
|
+
}
|
|
4566
|
+
super(textbus, state);
|
|
4567
|
+
this.focus = new core$1.Subject();
|
|
4568
|
+
this.members = core.createSignal([]);
|
|
4569
|
+
this.selectedIndex = core.createSignal(0);
|
|
4570
|
+
}
|
|
4571
|
+
getSlots() {
|
|
4572
|
+
if (this.state.slot) {
|
|
4573
|
+
return [this.state.slot];
|
|
4574
|
+
}
|
|
4575
|
+
return [];
|
|
4576
|
+
}
|
|
4577
|
+
setup() {
|
|
4578
|
+
let isFocus = false;
|
|
4579
|
+
core$1.onFocus(() => {
|
|
4580
|
+
isFocus = true;
|
|
4581
|
+
this.focus.next(true);
|
|
4582
|
+
onChange.next();
|
|
4583
|
+
});
|
|
4584
|
+
core$1.onBlur(() => {
|
|
4585
|
+
isFocus = false;
|
|
4586
|
+
this.focus.next(false);
|
|
4587
|
+
setTimeout(() => {
|
|
4588
|
+
if (this.parent && !this.state.userInfo) {
|
|
4589
|
+
const slot = this.state.slot;
|
|
4590
|
+
let text = '@';
|
|
4591
|
+
if (slot) {
|
|
4592
|
+
text += slot.isEmpty ? '' : slot.toString();
|
|
4593
|
+
}
|
|
4594
|
+
const snapshot = selection.createSnapshot();
|
|
4595
|
+
selection.selectComponent(this);
|
|
4596
|
+
commander.insert(text);
|
|
4597
|
+
snapshot.restore(true);
|
|
4598
|
+
}
|
|
4599
|
+
});
|
|
4600
|
+
});
|
|
4601
|
+
const organization = core$1.useContext(Organization);
|
|
4602
|
+
const selection = core$1.useContext(core$1.Selection);
|
|
4603
|
+
const commander = core$1.useContext(core$1.Commander);
|
|
4604
|
+
const onChange = new core$1.Subject();
|
|
4605
|
+
core$1.onContentInserted((ev) => {
|
|
4606
|
+
const key = this.state.slot.toString();
|
|
4607
|
+
if (key.length > 10) {
|
|
4608
|
+
selection.selectComponent(this);
|
|
4609
|
+
commander.insert(key);
|
|
4610
|
+
ev.preventDefault();
|
|
4611
|
+
return;
|
|
4612
|
+
}
|
|
4613
|
+
onChange.next();
|
|
4614
|
+
});
|
|
4615
|
+
core$1.onContentDeleted(() => {
|
|
4616
|
+
onChange.next();
|
|
4617
|
+
});
|
|
4618
|
+
core$1.onBreak((ev) => {
|
|
4619
|
+
const member = this.members()[this.selectedIndex()];
|
|
4620
|
+
if (member) {
|
|
4621
|
+
this.state.userInfo = Object.assign({}, member);
|
|
4622
|
+
}
|
|
4623
|
+
selection.selectComponentEnd(this);
|
|
4624
|
+
ev.preventDefault();
|
|
4625
|
+
});
|
|
4626
|
+
core$1.useDynamicShortcut({
|
|
4627
|
+
keymap: {
|
|
4628
|
+
key: ['ArrowDown', 'ArrowUp']
|
|
4629
|
+
},
|
|
4630
|
+
action: (key) => {
|
|
4631
|
+
let index = this.selectedIndex();
|
|
4632
|
+
if (key === 'ArrowUp') {
|
|
4633
|
+
if (index > 0) {
|
|
4634
|
+
index--;
|
|
4635
|
+
this.selectedIndex.set(index);
|
|
4636
|
+
}
|
|
4637
|
+
return;
|
|
4638
|
+
}
|
|
4639
|
+
if (index < this.members().length - 1) {
|
|
4640
|
+
index++;
|
|
4641
|
+
this.selectedIndex.set(index);
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
});
|
|
4645
|
+
const subs = onChange.pipe(core$1.switchMap(() => {
|
|
4646
|
+
const key = this.state.slot.toString();
|
|
4647
|
+
return core$1.fromPromise(organization.getMembers(key));
|
|
4648
|
+
})).subscribe((members) => {
|
|
4649
|
+
this.members.set(members);
|
|
4650
|
+
this.selectedIndex.set(0);
|
|
4651
|
+
if (isFocus) {
|
|
4652
|
+
this.focus.next(true);
|
|
4653
|
+
}
|
|
4654
|
+
});
|
|
4655
|
+
core$1.onDestroy(() => {
|
|
4656
|
+
subs.unsubscribe();
|
|
4657
|
+
});
|
|
3813
4658
|
}
|
|
3814
4659
|
}
|
|
4660
|
+
AtComponent.componentName = 'AtComponent';
|
|
4661
|
+
AtComponent.type = core$1.ContentType.InlineComponent;
|
|
3815
4662
|
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
4663
|
+
function AtComponentView(props) {
|
|
4664
|
+
const selection = core.inject(core$1.Selection);
|
|
4665
|
+
const dropdownRef = core.createRef();
|
|
4666
|
+
const subscription = props.component.focus.subscribe((b) => {
|
|
4667
|
+
if (dropdownRef.current && props.component.members().length) {
|
|
4668
|
+
dropdownRef.current.isShow(b);
|
|
4669
|
+
}
|
|
4670
|
+
});
|
|
4671
|
+
core.onUnmounted(() => {
|
|
4672
|
+
subscription.unsubscribe();
|
|
4673
|
+
});
|
|
3826
4674
|
const readonly = useReadonly();
|
|
3827
4675
|
const output = useOutput();
|
|
4676
|
+
const membersRef = core.createRef();
|
|
4677
|
+
core.onUpdated(() => {
|
|
4678
|
+
if (output() || readonly()) {
|
|
4679
|
+
return;
|
|
4680
|
+
}
|
|
4681
|
+
const container = membersRef.current;
|
|
4682
|
+
if (container) {
|
|
4683
|
+
const focusItem = container.children[props.component.selectedIndex()];
|
|
4684
|
+
if (focusItem) {
|
|
4685
|
+
const itemRect = focusItem.getBoundingClientRect();
|
|
4686
|
+
const dropdownMenu = container.parentNode.parentNode;
|
|
4687
|
+
const containerRect = dropdownMenu.getBoundingClientRect();
|
|
4688
|
+
if (itemRect.top - 5 < containerRect.top) {
|
|
4689
|
+
dropdownMenu.scrollTop += itemRect.top - 5 - containerRect.top;
|
|
4690
|
+
}
|
|
4691
|
+
else if (itemRect.bottom + 5 > containerRect.bottom) {
|
|
4692
|
+
dropdownMenu.scrollTop += itemRect.bottom + 5 - containerRect.bottom;
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
});
|
|
3828
4697
|
return () => {
|
|
4698
|
+
const { slot, userInfo } = props.component.state;
|
|
4699
|
+
const selectedIndex = props.component.selectedIndex();
|
|
4700
|
+
if (userInfo) {
|
|
4701
|
+
return (jsxRuntime.jsxs("div", { class: "xnote-at xnote-at-complete", "data-info": encodeURIComponent(JSON.stringify(userInfo)), ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), userInfo.name] }));
|
|
4702
|
+
}
|
|
3829
4703
|
if (readonly() || output()) {
|
|
3830
|
-
return (jsxRuntime.
|
|
3831
|
-
width: state.width,
|
|
3832
|
-
height: state.height
|
|
3833
|
-
} }) }));
|
|
4704
|
+
return (jsxRuntime.jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, class: 'xnote-at-input', tag: "span" })] }));
|
|
3834
4705
|
}
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
4706
|
+
const members = props.component.members();
|
|
4707
|
+
return (jsxRuntime.jsx("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsxs(Dropdown, { trigger: 'none', ref: dropdownRef, menu: jsxRuntime.jsx("div", { class: "xnote-at-menu", ref: membersRef, children: members.map((member, index) => {
|
|
4708
|
+
let hsl = color.any2Hsl(member.color);
|
|
4709
|
+
if (hsl === 'unknown') {
|
|
4710
|
+
hsl = color.any2Hsl('#000');
|
|
4711
|
+
}
|
|
4712
|
+
const rgb = color.hsl2Rgb(hsl);
|
|
4713
|
+
const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
4714
|
+
const color$1 = yiq >= 128 ? '#000' : '#fff';
|
|
4715
|
+
return (jsxRuntime.jsxs("div", { onClick: () => {
|
|
4716
|
+
props.component.state.userInfo = member;
|
|
4717
|
+
selection.selectComponentEnd(props.component);
|
|
4718
|
+
}, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsxRuntime.jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsxRuntime.jsx("img", { src: member.avatar, alt: member.name }) :
|
|
4719
|
+
jsxRuntime.jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color: color$1 }, children: member.name }) }), jsxRuntime.jsxs("div", { class: "xnote-at-member-info", children: [jsxRuntime.jsx("div", { class: "xnote-at-member-name", children: member.name }), jsxRuntime.jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
|
|
4720
|
+
}) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
|
|
3839
4721
|
};
|
|
3840
4722
|
}
|
|
3841
|
-
const
|
|
4723
|
+
const atComponentLoader = {
|
|
3842
4724
|
match(element) {
|
|
3843
|
-
return element.
|
|
4725
|
+
return element.dataset.component === AtComponent.componentName;
|
|
3844
4726
|
},
|
|
3845
|
-
read(element, textbus) {
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
4727
|
+
read(element, textbus, slotParser) {
|
|
4728
|
+
const data = element.dataset.info;
|
|
4729
|
+
if (data) {
|
|
4730
|
+
return new AtComponent(textbus, {
|
|
4731
|
+
userInfo: JSON.parse(decodeURIComponent(data))
|
|
4732
|
+
});
|
|
4733
|
+
}
|
|
4734
|
+
const slot = slotParser(new core$1.Slot([core$1.ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
|
|
4735
|
+
return new AtComponent(textbus, {
|
|
4736
|
+
slot
|
|
3849
4737
|
});
|
|
3850
4738
|
}
|
|
3851
4739
|
};
|
|
@@ -3856,33 +4744,25 @@ class RootComponent extends core$1.Component {
|
|
|
3856
4744
|
this.onCompositionStart = new core$1.Subject();
|
|
3857
4745
|
}
|
|
3858
4746
|
static fromJSON(textbus, json) {
|
|
3859
|
-
const heading = textbus.get(core$1.Registry).createSlot(json.heading);
|
|
3860
4747
|
const content = textbus.get(core$1.Registry).createSlot(json.content);
|
|
3861
4748
|
return new RootComponent(textbus, {
|
|
3862
|
-
heading,
|
|
3863
4749
|
content
|
|
3864
4750
|
});
|
|
3865
4751
|
}
|
|
4752
|
+
getSlots() {
|
|
4753
|
+
return [this.state.content];
|
|
4754
|
+
}
|
|
3866
4755
|
setup() {
|
|
3867
|
-
|
|
3868
|
-
const selection = textbus.get(core$1.Selection);
|
|
3869
|
-
core$1.onBreak(ev => {
|
|
3870
|
-
if (ev.target === this.state.heading) {
|
|
3871
|
-
const afterContent = ev.target.cut(ev.data.index);
|
|
3872
|
-
const p = new ParagraphComponent(textbus, {
|
|
3873
|
-
slot: afterContent
|
|
3874
|
-
});
|
|
3875
|
-
const body = this.state.content;
|
|
3876
|
-
body.retain(0);
|
|
3877
|
-
body.insert(p);
|
|
3878
|
-
selection.setPosition(afterContent, 0);
|
|
3879
|
-
ev.preventDefault();
|
|
3880
|
-
}
|
|
3881
|
-
});
|
|
3882
|
-
useBlockContent(this.state.content);
|
|
4756
|
+
useBlockContent((slot) => slot === this.state.content);
|
|
3883
4757
|
core$1.onCompositionStart(ev => {
|
|
3884
4758
|
this.onCompositionStart.next(ev);
|
|
3885
4759
|
});
|
|
4760
|
+
core$1.onSlotSetAttribute(ev => {
|
|
4761
|
+
ev.preventDefault();
|
|
4762
|
+
});
|
|
4763
|
+
core$1.onSlotApplyFormat(ev => {
|
|
4764
|
+
ev.preventDefault();
|
|
4765
|
+
});
|
|
3886
4766
|
}
|
|
3887
4767
|
afterCheck() {
|
|
3888
4768
|
const content = this.state.content;
|
|
@@ -3899,16 +4779,10 @@ class RootComponent extends core$1.Component {
|
|
|
3899
4779
|
RootComponent.componentName = 'RootComponent';
|
|
3900
4780
|
RootComponent.type = core$1.ContentType.BlockComponent;
|
|
3901
4781
|
function RootView(props) {
|
|
3902
|
-
const
|
|
3903
|
-
const { heading, content } = props.component.state;
|
|
4782
|
+
const { content } = props.component.state;
|
|
3904
4783
|
const ref = core.createDynamicRef(node => {
|
|
3905
|
-
const sub = props.component.onCompositionStart.subscribe(
|
|
3906
|
-
|
|
3907
|
-
node.children[0].dataset.placeholder = '';
|
|
3908
|
-
}
|
|
3909
|
-
else {
|
|
3910
|
-
node.children[1].dataset.placeholder = '';
|
|
3911
|
-
}
|
|
4784
|
+
const sub = props.component.onCompositionStart.subscribe(() => {
|
|
4785
|
+
node.children[0].dataset.placeholder = '';
|
|
3912
4786
|
});
|
|
3913
4787
|
return () => {
|
|
3914
4788
|
sub.unsubscribe();
|
|
@@ -3918,19 +4792,10 @@ function RootView(props) {
|
|
|
3918
4792
|
props.component.afterCheck();
|
|
3919
4793
|
});
|
|
3920
4794
|
const readonly = useReadonly();
|
|
4795
|
+
const output = useOutput();
|
|
3921
4796
|
return () => {
|
|
3922
4797
|
const { rootRef } = props;
|
|
3923
|
-
return (jsxRuntime.
|
|
3924
|
-
return (core$1.createVNode('div', {
|
|
3925
|
-
class: 'xnote-title',
|
|
3926
|
-
'data-placeholder': heading.isEmpty ? '请输入标题' : ''
|
|
3927
|
-
}, children));
|
|
3928
|
-
}, readonly()), adapter.slotRender(content, children => {
|
|
3929
|
-
return (core$1.createVNode('div', {
|
|
3930
|
-
class: 'xnote-content',
|
|
3931
|
-
'data-placeholder': content.isEmpty ? '请输入内容' : ''
|
|
3932
|
-
}, children));
|
|
3933
|
-
}, readonly())] }));
|
|
4798
|
+
return (jsxRuntime.jsx("div", { class: "xnote-root", dir: "auto", ref: [rootRef, ref], "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: content, tag: "div", class: "xnote-content", "data-placeholder": content.isEmpty ? '请输入内容' : '', renderEnv: readonly() || output() }) }));
|
|
3934
4799
|
};
|
|
3935
4800
|
}
|
|
3936
4801
|
const rootComponentLoader = {
|
|
@@ -3944,9 +4809,7 @@ const rootComponentLoader = {
|
|
|
3944
4809
|
core$1.ContentType.Text
|
|
3945
4810
|
]), element).toDelta();
|
|
3946
4811
|
const slot = new core$1.Slot([
|
|
3947
|
-
core$1.ContentType.BlockComponent
|
|
3948
|
-
core$1.ContentType.InlineComponent,
|
|
3949
|
-
core$1.ContentType.Text
|
|
4812
|
+
core$1.ContentType.BlockComponent
|
|
3950
4813
|
]);
|
|
3951
4814
|
deltaToBlock(delta, textbus).forEach(i => {
|
|
3952
4815
|
slot.insert(i);
|
|
@@ -3955,7 +4818,7 @@ const rootComponentLoader = {
|
|
|
3955
4818
|
}
|
|
3956
4819
|
};
|
|
3957
4820
|
|
|
3958
|
-
var
|
|
4821
|
+
var scopedId$5 = "vf-681de2";
|
|
3959
4822
|
|
|
3960
4823
|
let TableService = class TableService {
|
|
3961
4824
|
constructor() {
|
|
@@ -3973,6 +4836,7 @@ TableService = __decorate([
|
|
|
3973
4836
|
function ResizeColumn(props) {
|
|
3974
4837
|
const dragLineRef = core.createRef();
|
|
3975
4838
|
let activeCol = null;
|
|
4839
|
+
const editorService = core.inject(exports.EditorService);
|
|
3976
4840
|
core.onMounted(() => {
|
|
3977
4841
|
const { tableRef } = props;
|
|
3978
4842
|
let isDrag = false;
|
|
@@ -4005,6 +4869,7 @@ function ResizeColumn(props) {
|
|
|
4005
4869
|
}
|
|
4006
4870
|
})).add(core$1.fromEvent(dragLineRef.current, 'mousedown').subscribe(downEvent => {
|
|
4007
4871
|
isDrag = true;
|
|
4872
|
+
editorService.changeLeftToolbarVisible(false);
|
|
4008
4873
|
props.onActiveStateChange(true);
|
|
4009
4874
|
const x = downEvent.clientX;
|
|
4010
4875
|
const layoutWidth = props.component.state.layoutWidth;
|
|
@@ -4012,16 +4877,20 @@ function ResizeColumn(props) {
|
|
|
4012
4877
|
const initLeft = layoutWidth.slice(0, activeCol).reduce((a, b) => a + b, 0);
|
|
4013
4878
|
const minWidth = 30;
|
|
4014
4879
|
const minLeft = initLeft - initWidth + minWidth;
|
|
4880
|
+
const layoutWidthArr = layoutWidth.slice();
|
|
4015
4881
|
const moveEvent = core$1.fromEvent(document, 'mousemove').subscribe(moveEvent => {
|
|
4016
4882
|
const distanceX = moveEvent.clientX - x;
|
|
4017
4883
|
dragLineRef.current.style.left = Math.max(initLeft + distanceX, minLeft) + 'px';
|
|
4018
|
-
|
|
4884
|
+
layoutWidthArr[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
|
|
4885
|
+
props.layoutWidth.set(layoutWidthArr.slice());
|
|
4019
4886
|
}).add(core$1.fromEvent(document, 'mouseup').subscribe(upEvent => {
|
|
4020
4887
|
isDrag = false;
|
|
4888
|
+
editorService.changeLeftToolbarVisible(true);
|
|
4021
4889
|
props.onActiveStateChange(false);
|
|
4022
4890
|
moveEvent.unsubscribe();
|
|
4023
4891
|
const distanceX = upEvent.clientX - x;
|
|
4024
4892
|
props.component.state.layoutWidth[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
|
|
4893
|
+
props.layoutWidth.set(props.component.state.layoutWidth);
|
|
4025
4894
|
}));
|
|
4026
4895
|
}));
|
|
4027
4896
|
return () => {
|
|
@@ -4042,12 +4911,12 @@ function ResizeColumn(props) {
|
|
|
4042
4911
|
});
|
|
4043
4912
|
return () => sub.unsubscribe();
|
|
4044
4913
|
});
|
|
4045
|
-
return scopedCss.withScopedCSS(
|
|
4914
|
+
return scopedCss.withScopedCSS(scopedId$5, () => {
|
|
4046
4915
|
return jsxRuntime.jsx("div", { ref: dragLineRef, class: ['drag-line'] });
|
|
4047
4916
|
});
|
|
4048
4917
|
}
|
|
4049
4918
|
|
|
4050
|
-
var
|
|
4919
|
+
var scopedId$4 = "vf-39cb2c";
|
|
4051
4920
|
|
|
4052
4921
|
function TopBar(props) {
|
|
4053
4922
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4115,14 +4984,14 @@ function TopBar(props) {
|
|
|
4115
4984
|
s.unsubscribe();
|
|
4116
4985
|
});
|
|
4117
4986
|
const deleteIndex = core.createSignal(null);
|
|
4118
|
-
return scopedCss.withScopedCSS(
|
|
4987
|
+
return scopedCss.withScopedCSS(scopedId$4, () => {
|
|
4119
4988
|
const { state, tableSelection } = props.component;
|
|
4120
4989
|
const position = tableSelection();
|
|
4121
4990
|
return (jsxRuntime.jsx("div", { class: ['top-bar', {
|
|
4122
4991
|
active: props.isFocus()
|
|
4123
4992
|
}], children: jsxRuntime.jsxs("div", { class: "toolbar-wrapper", children: [jsxRuntime.jsx("div", { class: "insert-bar", children: jsxRuntime.jsx("table", { style: {
|
|
4124
4993
|
transform: `translateX(${-leftDistance()}px)`
|
|
4125
|
-
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children:
|
|
4994
|
+
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
4126
4995
|
return (jsxRuntime.jsx("td", { style: { width: i + 'px', minWidth: i + 'px' }, children: jsxRuntime.jsxs("div", { class: "tool-container", children: [index === 0 && (jsxRuntime.jsx("span", { onMouseenter: () => {
|
|
4127
4996
|
tableService.onInsertColumnBefore.next(0);
|
|
4128
4997
|
}, onMouseleave: () => {
|
|
@@ -4148,7 +5017,7 @@ function TopBar(props) {
|
|
|
4148
5017
|
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }) }) }) })] }) }));
|
|
4149
5018
|
}) }) }) }) }), jsxRuntime.jsx("div", { class: ['action-bar', { active: props.isFocus() }], children: jsxRuntime.jsx("table", { style: {
|
|
4150
5019
|
transform: `translateX(${-leftDistance()}px)`
|
|
4151
|
-
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children:
|
|
5020
|
+
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
4152
5021
|
return jsxRuntime.jsx("td", { onClick: ev => {
|
|
4153
5022
|
mouseDownFromToolbar = true;
|
|
4154
5023
|
if (!ev.shiftKey) {
|
|
@@ -4168,7 +5037,7 @@ function TopBar(props) {
|
|
|
4168
5037
|
});
|
|
4169
5038
|
}
|
|
4170
5039
|
|
|
4171
|
-
var
|
|
5040
|
+
var scopedId$3 = "vf-7bef30";
|
|
4172
5041
|
|
|
4173
5042
|
function Scroll(props) {
|
|
4174
5043
|
const scrollRef = core.createRef();
|
|
@@ -4182,37 +5051,41 @@ function Scroll(props) {
|
|
|
4182
5051
|
const el = scrollRef.current;
|
|
4183
5052
|
function update() {
|
|
4184
5053
|
if (props.isFocus()) {
|
|
4185
|
-
input.caret.refresh(
|
|
5054
|
+
input.caret.refresh();
|
|
4186
5055
|
}
|
|
4187
5056
|
updateShowShadow(draft => {
|
|
4188
5057
|
draft.leftEnd = el.scrollLeft === 0;
|
|
4189
5058
|
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
4190
5059
|
});
|
|
4191
5060
|
}
|
|
4192
|
-
update
|
|
5061
|
+
setTimeout(update);
|
|
4193
5062
|
const s = core$1.fromEvent(el, 'scroll').subscribe(update);
|
|
4194
5063
|
return () => s.unsubscribe();
|
|
4195
5064
|
});
|
|
4196
5065
|
core.onUpdated(() => {
|
|
4197
5066
|
const el = scrollRef.current;
|
|
4198
|
-
|
|
4199
|
-
draft
|
|
4200
|
-
|
|
5067
|
+
setTimeout(() => {
|
|
5068
|
+
updateShowShadow(draft => {
|
|
5069
|
+
draft.leftEnd = el.scrollLeft === 0;
|
|
5070
|
+
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
5071
|
+
});
|
|
4201
5072
|
});
|
|
4202
5073
|
});
|
|
4203
|
-
return scopedCss.withScopedCSS(
|
|
4204
|
-
return jsxRuntime.jsx("div", { ref: [scrollRef
|
|
5074
|
+
return scopedCss.withScopedCSS(scopedId$3, () => {
|
|
5075
|
+
return jsxRuntime.jsx("div", { ref: [scrollRef], class: ['scroll-container', {
|
|
4205
5076
|
'left-end': showShadow().leftEnd,
|
|
4206
5077
|
'right-end': showShadow().rightEnd,
|
|
4207
5078
|
'active': props.isFocus(),
|
|
4208
5079
|
// 'hide-selection': isSelectColumn()
|
|
4209
5080
|
}], onScroll: ev => {
|
|
4210
|
-
|
|
5081
|
+
setTimeout(() => {
|
|
5082
|
+
tableService.onScroll.next(ev.target.scrollLeft);
|
|
5083
|
+
}, 30);
|
|
4211
5084
|
}, children: props.children });
|
|
4212
5085
|
});
|
|
4213
5086
|
}
|
|
4214
5087
|
|
|
4215
|
-
var
|
|
5088
|
+
var scopedId$2 = "vf-aaece0";
|
|
4216
5089
|
|
|
4217
5090
|
function LeftBar(props) {
|
|
4218
5091
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4286,7 +5159,7 @@ function LeftBar(props) {
|
|
|
4286
5159
|
textbus.focus();
|
|
4287
5160
|
});
|
|
4288
5161
|
}
|
|
4289
|
-
return scopedCss.withScopedCSS(
|
|
5162
|
+
return scopedCss.withScopedCSS(scopedId$2, () => {
|
|
4290
5163
|
const { state, tableSelection } = props.component;
|
|
4291
5164
|
const position = tableSelection();
|
|
4292
5165
|
return (jsxRuntime.jsxs("div", { class: ['left-bar', { active: props.isFocus() }], children: [jsxRuntime.jsx("div", { class: "insert-bar", children: jsxRuntime.jsx("table", { ref: insertBarRef, children: jsxRuntime.jsx("tbody", { children: state.rows.map((_, index) => {
|
|
@@ -4334,7 +5207,7 @@ function LeftBar(props) {
|
|
|
4334
5207
|
});
|
|
4335
5208
|
}
|
|
4336
5209
|
|
|
4337
|
-
var
|
|
5210
|
+
var scopedId$1 = "vf-d4c4a9";
|
|
4338
5211
|
|
|
4339
5212
|
function sum(numbers) {
|
|
4340
5213
|
return numbers.reduce((a, b) => a + b, 0);
|
|
@@ -4367,7 +5240,7 @@ function ResizeRow(props) {
|
|
|
4367
5240
|
});
|
|
4368
5241
|
return () => sub.unsubscribe();
|
|
4369
5242
|
});
|
|
4370
|
-
return scopedCss.withScopedCSS(
|
|
5243
|
+
return scopedCss.withScopedCSS(scopedId$1, () => {
|
|
4371
5244
|
return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
|
|
4372
5245
|
display: styles().visible ? 'block' : 'none',
|
|
4373
5246
|
top: styles().top + 'px',
|
|
@@ -4376,7 +5249,7 @@ function ResizeRow(props) {
|
|
|
4376
5249
|
});
|
|
4377
5250
|
}
|
|
4378
5251
|
|
|
4379
|
-
var
|
|
5252
|
+
var scopedId = "vf-4a5ad1";
|
|
4380
5253
|
|
|
4381
5254
|
function SelectionMask(props) {
|
|
4382
5255
|
const [styles, updateStyles] = hooks.useProduce({
|
|
@@ -4412,9 +5285,9 @@ function SelectionMask(props) {
|
|
|
4412
5285
|
updateStyles(draft => {
|
|
4413
5286
|
draft.visible = true;
|
|
4414
5287
|
draft.left = sum(state.layoutWidth.slice(0, selection.startColumn));
|
|
4415
|
-
draft.top =
|
|
5288
|
+
draft.top = trs[selection.startRow].offsetTop + topCompensation;
|
|
4416
5289
|
draft.width = sum(state.layoutWidth.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
|
|
4417
|
-
draft.height =
|
|
5290
|
+
draft.height = trs[selection.endRow - 1].offsetTop + trs[selection.endRow - 1].offsetHeight + heightCompensation - draft.top + 'px';
|
|
4418
5291
|
});
|
|
4419
5292
|
}
|
|
4420
5293
|
else {
|
|
@@ -4429,7 +5302,7 @@ function SelectionMask(props) {
|
|
|
4429
5302
|
core.onUnmounted(() => {
|
|
4430
5303
|
s.unsubscribe();
|
|
4431
5304
|
});
|
|
4432
|
-
return scopedCss.withScopedCSS(
|
|
5305
|
+
return scopedCss.withScopedCSS(scopedId, () => {
|
|
4433
5306
|
const style = styles();
|
|
4434
5307
|
return (jsxRuntime.jsx("div", { class: "mask", style: {
|
|
4435
5308
|
display: style.visible ? 'block' : 'none',
|
|
@@ -4443,81 +5316,25 @@ function SelectionMask(props) {
|
|
|
4443
5316
|
});
|
|
4444
5317
|
}
|
|
4445
5318
|
|
|
5319
|
+
// import { SlotRender } from '../SlotRender'
|
|
4446
5320
|
const TableComponentView = core.withAnnotation({
|
|
4447
5321
|
providers: [TableService]
|
|
4448
5322
|
}, function TableComponentView(props) {
|
|
4449
5323
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
5324
|
+
const editorService = core.inject(exports.EditorService);
|
|
4450
5325
|
const isFocus = core.createSignal(false);
|
|
5326
|
+
const layoutWidth = core.createSignal(props.component.state.layoutWidth);
|
|
4451
5327
|
const subscription = props.component.focus.subscribe(b => {
|
|
4452
5328
|
isFocus.set(b);
|
|
5329
|
+
if (!b) {
|
|
5330
|
+
editorService.hideInlineToolbar = false;
|
|
5331
|
+
}
|
|
4453
5332
|
});
|
|
4454
5333
|
core.onUnmounted(() => {
|
|
4455
5334
|
subscription.unsubscribe();
|
|
4456
5335
|
});
|
|
4457
5336
|
const tableRef = core.createRef();
|
|
4458
|
-
const scrollRef = core.createRef();
|
|
4459
5337
|
const isResizeColumn = core.createSignal(false);
|
|
4460
|
-
const selection = core.inject(core$1.Selection);
|
|
4461
|
-
const findPosition = (slot) => {
|
|
4462
|
-
let cell = slot;
|
|
4463
|
-
while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== props.component) {
|
|
4464
|
-
cell = cell.parentSlot;
|
|
4465
|
-
}
|
|
4466
|
-
if (cell) {
|
|
4467
|
-
const rows = props.component.state.rows;
|
|
4468
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
4469
|
-
const row = rows[rowIndex].cells;
|
|
4470
|
-
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
|
4471
|
-
const item = row[colIndex].slot;
|
|
4472
|
-
if (item === cell) {
|
|
4473
|
-
return {
|
|
4474
|
-
rowIndex,
|
|
4475
|
-
colIndex
|
|
4476
|
-
};
|
|
4477
|
-
}
|
|
4478
|
-
}
|
|
4479
|
-
}
|
|
4480
|
-
}
|
|
4481
|
-
return null;
|
|
4482
|
-
};
|
|
4483
|
-
core.onMounted(() => {
|
|
4484
|
-
const sub = selection.onChange.subscribe(() => {
|
|
4485
|
-
var _a;
|
|
4486
|
-
if (selection.commonAncestorComponent !== props.component || selection.isCollapsed) {
|
|
4487
|
-
props.component.tableSelection.set(null);
|
|
4488
|
-
return;
|
|
4489
|
-
}
|
|
4490
|
-
const startPosition = findPosition(selection.startSlot);
|
|
4491
|
-
const endPosition = findPosition(selection.endSlot);
|
|
4492
|
-
if (startPosition && endPosition) {
|
|
4493
|
-
if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
|
|
4494
|
-
if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
4495
|
-
props.component.tableSelection.set({
|
|
4496
|
-
startColumn: startPosition.colIndex,
|
|
4497
|
-
startRow: startPosition.rowIndex,
|
|
4498
|
-
endColumn: endPosition.colIndex + 1,
|
|
4499
|
-
endRow: endPosition.rowIndex + 1
|
|
4500
|
-
});
|
|
4501
|
-
return;
|
|
4502
|
-
}
|
|
4503
|
-
props.component.tableSelection.set(null);
|
|
4504
|
-
return;
|
|
4505
|
-
}
|
|
4506
|
-
const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
|
|
4507
|
-
const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
|
|
4508
|
-
props.component.tableSelection.set({
|
|
4509
|
-
startColumn,
|
|
4510
|
-
startRow,
|
|
4511
|
-
endColumn: endColumn + 1,
|
|
4512
|
-
endRow: endRow + 1
|
|
4513
|
-
});
|
|
4514
|
-
}
|
|
4515
|
-
else {
|
|
4516
|
-
props.component.tableSelection.set(null);
|
|
4517
|
-
}
|
|
4518
|
-
});
|
|
4519
|
-
return () => sub.unsubscribe();
|
|
4520
|
-
});
|
|
4521
5338
|
const rowMapping = new WeakMap();
|
|
4522
5339
|
const readonly = useReadonly();
|
|
4523
5340
|
const output = useOutput();
|
|
@@ -4530,45 +5347,42 @@ const TableComponentView = core.withAnnotation({
|
|
|
4530
5347
|
}
|
|
4531
5348
|
rowMapping.set(row, Math.random());
|
|
4532
5349
|
});
|
|
4533
|
-
Promise.resolve().then(() => {
|
|
4534
|
-
props.component.afterContentCheck();
|
|
4535
|
-
});
|
|
4536
5350
|
if (readonly() || output()) {
|
|
4537
|
-
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
}
|
|
4554
|
-
return (jsxRuntime.
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
5351
|
+
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
|
|
5352
|
+
'xnote-table-content',
|
|
5353
|
+
{
|
|
5354
|
+
'hide-selection': props.component.tableSelection()
|
|
5355
|
+
}
|
|
5356
|
+
], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
|
|
5357
|
+
return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
5358
|
+
}) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
|
|
5359
|
+
return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
|
|
5360
|
+
return adapter.slotRender(cell.slot, children => {
|
|
5361
|
+
return core$1.createVNode('td', {
|
|
5362
|
+
key: cell.slot.id
|
|
5363
|
+
}, children);
|
|
5364
|
+
}, readonly() || output());
|
|
5365
|
+
}) }, rowMapping.get(row)));
|
|
5366
|
+
}) })] }) }) }) }));
|
|
5367
|
+
}
|
|
5368
|
+
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.layoutWidth.join(',')}]`, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
|
|
5369
|
+
'xnote-table-content',
|
|
5370
|
+
{
|
|
5371
|
+
'hide-selection': props.component.tableSelection()
|
|
5372
|
+
}
|
|
5373
|
+
], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
|
|
5374
|
+
return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
5375
|
+
}) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
|
|
5376
|
+
return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
|
|
5377
|
+
return adapter.slotRender(cell.slot, children => {
|
|
5378
|
+
return core$1.createVNode('td', {
|
|
5379
|
+
key: cell.slot.id
|
|
5380
|
+
}, children);
|
|
5381
|
+
}, readonly() || output());
|
|
5382
|
+
}) }, rowMapping.get(row)));
|
|
5383
|
+
}) })] }), jsxRuntime.jsx(ResizeColumn, { tableRef: tableRef, component: props.component, layoutWidth: layoutWidth, onActiveStateChange: isActive => {
|
|
5384
|
+
isResizeColumn.set(isActive);
|
|
5385
|
+
} }), jsxRuntime.jsx(SelectionMask, { tableRef: tableRef, component: props.component })] }) }), jsxRuntime.jsx(ResizeRow, { component: props.component, tableRef: tableRef })] }) }));
|
|
4572
5386
|
};
|
|
4573
5387
|
});
|
|
4574
5388
|
const tableComponentLoader = {
|
|
@@ -4576,10 +5390,11 @@ const tableComponentLoader = {
|
|
|
4576
5390
|
return element.dataset.component === TableComponent.componentName || element.tagName === 'TABLE';
|
|
4577
5391
|
},
|
|
4578
5392
|
read(element, textbus, slotParser) {
|
|
5393
|
+
let content = element;
|
|
4579
5394
|
if (element.tagName === 'DIV') {
|
|
4580
|
-
|
|
5395
|
+
content = element.querySelector('.xnote-table-content');
|
|
4581
5396
|
}
|
|
4582
|
-
const { tHead, tBodies, tFoot } =
|
|
5397
|
+
const { tHead, tBodies, tFoot } = content;
|
|
4583
5398
|
const headers = [];
|
|
4584
5399
|
const bodies = [];
|
|
4585
5400
|
if (tHead) {
|
|
@@ -4589,8 +5404,6 @@ const tableComponentLoader = {
|
|
|
4589
5404
|
Array.from(row.cells).forEach(cell => {
|
|
4590
5405
|
const slot = new core$1.Slot([
|
|
4591
5406
|
core$1.ContentType.BlockComponent,
|
|
4592
|
-
core$1.ContentType.InlineComponent,
|
|
4593
|
-
core$1.ContentType.Text
|
|
4594
5407
|
]);
|
|
4595
5408
|
arr.push({
|
|
4596
5409
|
slot,
|
|
@@ -4618,8 +5431,6 @@ const tableComponentLoader = {
|
|
|
4618
5431
|
Array.from(row.cells).forEach(cell => {
|
|
4619
5432
|
const slot = new core$1.Slot([
|
|
4620
5433
|
core$1.ContentType.BlockComponent,
|
|
4621
|
-
core$1.ContentType.InlineComponent,
|
|
4622
|
-
core$1.ContentType.Text
|
|
4623
5434
|
]);
|
|
4624
5435
|
arr.push({
|
|
4625
5436
|
slot,
|
|
@@ -4706,8 +5517,6 @@ function autoComplete(table) {
|
|
|
4706
5517
|
rowspan: 1,
|
|
4707
5518
|
colspan: 1,
|
|
4708
5519
|
slot: new core$1.Slot([
|
|
4709
|
-
core$1.ContentType.Text,
|
|
4710
|
-
core$1.ContentType.InlineComponent,
|
|
4711
5520
|
core$1.ContentType.BlockComponent
|
|
4712
5521
|
])
|
|
4713
5522
|
};
|
|
@@ -4727,48 +5536,90 @@ function autoComplete(table) {
|
|
|
4727
5536
|
});
|
|
4728
5537
|
}
|
|
4729
5538
|
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
5539
|
+
function findFocusCell(table, slot) {
|
|
5540
|
+
var _a;
|
|
5541
|
+
while (slot) {
|
|
5542
|
+
if (table.slots.includes(slot)) {
|
|
5543
|
+
return slot;
|
|
5544
|
+
}
|
|
5545
|
+
slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
4736
5546
|
}
|
|
5547
|
+
return null;
|
|
4737
5548
|
}
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
5549
|
+
let TableSelectionAwarenessDelegate = class TableSelectionAwarenessDelegate extends platformBrowser.CollaborateSelectionAwarenessDelegate {
|
|
5550
|
+
constructor(domAdapter, selection) {
|
|
5551
|
+
super();
|
|
5552
|
+
this.domAdapter = domAdapter;
|
|
5553
|
+
this.selection = selection;
|
|
5554
|
+
}
|
|
5555
|
+
getRects(abstractSelection) {
|
|
5556
|
+
const { focusSlot, anchorSlot } = abstractSelection;
|
|
5557
|
+
const focusPaths = this.selection.getPathsBySlot(focusSlot);
|
|
5558
|
+
const anchorPaths = this.selection.getPathsBySlot(anchorSlot);
|
|
5559
|
+
const focusIsStart = core$1.Selection.compareSelectionPaths(focusPaths, anchorPaths);
|
|
5560
|
+
let startSlot;
|
|
5561
|
+
let endSlot;
|
|
5562
|
+
if (focusIsStart) {
|
|
5563
|
+
startSlot = focusSlot;
|
|
5564
|
+
endSlot = anchorSlot;
|
|
4751
5565
|
}
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
5566
|
+
else {
|
|
5567
|
+
startSlot = anchorSlot;
|
|
5568
|
+
endSlot = focusSlot;
|
|
5569
|
+
}
|
|
5570
|
+
const commonAncestorComponent = core$1.Selection.getCommonAncestorComponent(startSlot, endSlot);
|
|
5571
|
+
if (!(commonAncestorComponent instanceof TableComponent)) {
|
|
5572
|
+
return false;
|
|
5573
|
+
}
|
|
5574
|
+
const range = getSelectedRanges(commonAncestorComponent, findFocusCell(commonAncestorComponent, startSlot), findFocusCell(commonAncestorComponent, endSlot));
|
|
5575
|
+
const rows = commonAncestorComponent.state.rows;
|
|
5576
|
+
const startFocusSlot = rows[range.startRow].cells[range.startColumn].slot;
|
|
5577
|
+
const endFocusSlot = rows[range.endRow].cells[range.endColumn].slot;
|
|
5578
|
+
const renderer = this.domAdapter;
|
|
5579
|
+
const startRect = renderer.getNativeNodeBySlot(startFocusSlot).getBoundingClientRect();
|
|
5580
|
+
const endRect = renderer.getNativeNodeBySlot(endFocusSlot).getBoundingClientRect();
|
|
5581
|
+
return [{
|
|
5582
|
+
left: startRect.left,
|
|
5583
|
+
top: startRect.top,
|
|
5584
|
+
width: endRect.left + endRect.width - startRect.left,
|
|
5585
|
+
height: endRect.top + endRect.height - startRect.top
|
|
5586
|
+
}];
|
|
5587
|
+
}
|
|
5588
|
+
};
|
|
5589
|
+
TableSelectionAwarenessDelegate = __decorate([
|
|
5590
|
+
core.Injectable(),
|
|
5591
|
+
__metadata("design:paramtypes", [platformBrowser.DomAdapter,
|
|
5592
|
+
core$1.Selection])
|
|
5593
|
+
], TableSelectionAwarenessDelegate);
|
|
5594
|
+
function getSelectedRanges(component, startSlot, endSlot) {
|
|
5595
|
+
const p1 = finedPosition(component, startSlot);
|
|
5596
|
+
const p2 = finedPosition(component, endSlot);
|
|
5597
|
+
return {
|
|
5598
|
+
startRow: Math.min(p1.rowIndex, p2.rowIndex),
|
|
5599
|
+
endRow: Math.max(p1.rowIndex, p2.rowIndex),
|
|
5600
|
+
startColumn: Math.min(p1.columnIndex, p2.columnIndex),
|
|
5601
|
+
endColumn: Math.max(p1.columnIndex, p2.columnIndex)
|
|
4756
5602
|
};
|
|
4757
5603
|
}
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
5604
|
+
function finedPosition(component, slot) {
|
|
5605
|
+
const rows = component.state.rows;
|
|
5606
|
+
for (let i = 0; i < rows.length; i++) {
|
|
5607
|
+
const row = rows[i];
|
|
5608
|
+
for (let j = 0; j < row.cells.length; j++) {
|
|
5609
|
+
const cell = row.cells[j].slot;
|
|
5610
|
+
if (cell === slot) {
|
|
5611
|
+
return {
|
|
5612
|
+
rowIndex: i,
|
|
5613
|
+
columnIndex: j
|
|
5614
|
+
};
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
4767
5617
|
}
|
|
4768
|
-
|
|
5618
|
+
return null;
|
|
5619
|
+
}
|
|
4769
5620
|
|
|
4770
|
-
|
|
4771
|
-
|
|
5621
|
+
class Editor extends core$1.Textbus {
|
|
5622
|
+
constructor(editorConfig = {}) {
|
|
4772
5623
|
const adapter = new adapterViewfly.ViewflyAdapter({
|
|
4773
5624
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
4774
5625
|
[RootComponent.componentName]: RootView,
|
|
@@ -4779,19 +5630,59 @@ function createXNote(host_1) {
|
|
|
4779
5630
|
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4780
5631
|
[ListComponent.componentName]: ListComponentView,
|
|
4781
5632
|
[ImageComponent.componentName]: ImageView,
|
|
4782
|
-
[VideoComponent.componentName]: VideoView
|
|
5633
|
+
[VideoComponent.componentName]: VideoView,
|
|
5634
|
+
[AtComponent.componentName]: AtComponentView,
|
|
5635
|
+
[KatexComponent.componentName]: KatexComponentView,
|
|
4783
5636
|
}, (host, root, injector) => {
|
|
4784
5637
|
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4785
5638
|
provide: OutputInjectionToken,
|
|
4786
5639
|
useValue: false
|
|
4787
5640
|
}]);
|
|
4788
|
-
const app = platformBrowser$1.createApp(root, {
|
|
5641
|
+
const app = platformBrowser$1.createApp(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [root, jsxRuntime.jsx(LinkJump, {})] }), {
|
|
4789
5642
|
context: appInjector
|
|
4790
5643
|
}).mount(host);
|
|
4791
5644
|
return () => {
|
|
4792
5645
|
app.destroy();
|
|
4793
5646
|
};
|
|
4794
5647
|
});
|
|
5648
|
+
const browserModule = new platformBrowser.BrowserModule(Object.assign({ renderTo: () => {
|
|
5649
|
+
return this.host;
|
|
5650
|
+
}, useContentEditable: platformBrowser.isMobileBrowser(), adapter, componentLoaders: [
|
|
5651
|
+
atComponentLoader,
|
|
5652
|
+
sourceCodeComponentLoader,
|
|
5653
|
+
listComponentLoader,
|
|
5654
|
+
tableComponentLoader,
|
|
5655
|
+
imageComponentLoader,
|
|
5656
|
+
highlightBoxComponentLoader,
|
|
5657
|
+
blockquoteComponentLoader,
|
|
5658
|
+
videoComponentLoader,
|
|
5659
|
+
todolistComponentLoader,
|
|
5660
|
+
katexComponentLoader,
|
|
5661
|
+
paragraphComponentLoader,
|
|
5662
|
+
], formatLoaders: [
|
|
5663
|
+
backgroundColorFormatLoader,
|
|
5664
|
+
boldFormatLoader,
|
|
5665
|
+
codeFormatLoader,
|
|
5666
|
+
colorFormatLoader,
|
|
5667
|
+
fontFamilyFormatLoader,
|
|
5668
|
+
fontSizeFormatLoader,
|
|
5669
|
+
italicFormatLoader,
|
|
5670
|
+
linkFormatLoader,
|
|
5671
|
+
strikeThroughFormatLoader,
|
|
5672
|
+
underlineFormatLoader
|
|
5673
|
+
], attributeLoaders: [
|
|
5674
|
+
headingAttrLoader,
|
|
5675
|
+
textAlignAttrLoader,
|
|
5676
|
+
textIndentAttrLoader
|
|
5677
|
+
] }, editorConfig.viewOptions));
|
|
5678
|
+
const modules = [browserModule];
|
|
5679
|
+
if (editorConfig.collaborateConfig) {
|
|
5680
|
+
modules.push(new collaborate.CollaborateModule(editorConfig.collaborateConfig));
|
|
5681
|
+
browserModule.providers.push({
|
|
5682
|
+
provide: platformBrowser.CollaborateSelectionAwarenessDelegate,
|
|
5683
|
+
useClass: TableSelectionAwarenessDelegate
|
|
5684
|
+
});
|
|
5685
|
+
}
|
|
4795
5686
|
const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
|
|
4796
5687
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
4797
5688
|
[RootComponent.componentName]: RootView,
|
|
@@ -4802,14 +5693,16 @@ function createXNote(host_1) {
|
|
|
4802
5693
|
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4803
5694
|
[ListComponent.componentName]: ListComponentView,
|
|
4804
5695
|
[ImageComponent.componentName]: ImageView,
|
|
4805
|
-
[VideoComponent.componentName]: VideoView
|
|
5696
|
+
[VideoComponent.componentName]: VideoView,
|
|
5697
|
+
[AtComponent.componentName]: AtComponentView,
|
|
5698
|
+
[KatexComponent.componentName]: KatexComponentView
|
|
4806
5699
|
}, (host, root, injector) => {
|
|
4807
5700
|
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4808
5701
|
provide: OutputInjectionToken,
|
|
4809
5702
|
useValue: true
|
|
4810
5703
|
}, {
|
|
4811
5704
|
provide: platformBrowser.DomAdapter,
|
|
4812
|
-
useFactory() {
|
|
5705
|
+
useFactory: () => {
|
|
4813
5706
|
return vDomAdapter;
|
|
4814
5707
|
}
|
|
4815
5708
|
}]);
|
|
@@ -4821,50 +5714,7 @@ function createXNote(host_1) {
|
|
|
4821
5714
|
app.destroy();
|
|
4822
5715
|
};
|
|
4823
5716
|
});
|
|
4824
|
-
|
|
4825
|
-
renderTo() {
|
|
4826
|
-
return host;
|
|
4827
|
-
},
|
|
4828
|
-
adapter,
|
|
4829
|
-
componentLoaders: [
|
|
4830
|
-
highlightBoxComponentLoader,
|
|
4831
|
-
blockquoteComponentLoader,
|
|
4832
|
-
paragraphComponentLoader,
|
|
4833
|
-
sourceCodeComponentLoader,
|
|
4834
|
-
todolistComponentLoader,
|
|
4835
|
-
tableComponentLoader,
|
|
4836
|
-
listComponentLoader,
|
|
4837
|
-
imageComponentLoader,
|
|
4838
|
-
videoComponentLoader
|
|
4839
|
-
],
|
|
4840
|
-
formatLoaders: [
|
|
4841
|
-
backgroundColorFormatLoader,
|
|
4842
|
-
boldFormatLoader,
|
|
4843
|
-
codeFormatLoader,
|
|
4844
|
-
colorFormatLoader,
|
|
4845
|
-
fontFamilyFormatLoader,
|
|
4846
|
-
fontSizeFormatLoader,
|
|
4847
|
-
italicFormatLoader,
|
|
4848
|
-
linkFormatLoader,
|
|
4849
|
-
strikeThroughFormatLoader,
|
|
4850
|
-
underlineFormatLoader
|
|
4851
|
-
],
|
|
4852
|
-
attributeLoaders: [
|
|
4853
|
-
headingAttrLoader,
|
|
4854
|
-
textAlignAttrLoader,
|
|
4855
|
-
textIndentAttrLoader
|
|
4856
|
-
]
|
|
4857
|
-
});
|
|
4858
|
-
const modules = [browserModule];
|
|
4859
|
-
if (config.collaborateConfig) {
|
|
4860
|
-
modules.push(new collaborate.CollaborateModule(config.collaborateConfig));
|
|
4861
|
-
}
|
|
4862
|
-
const textbus = new core$1.Textbus({
|
|
4863
|
-
additionalAdapters: [vDomAdapter],
|
|
4864
|
-
zenCoding: true,
|
|
4865
|
-
readonly: config.readonly,
|
|
4866
|
-
imports: modules,
|
|
4867
|
-
components: [
|
|
5717
|
+
super(Object.assign({ zenCoding: true, additionalAdapters: [vDomAdapter], imports: modules, components: [
|
|
4868
5718
|
ImageComponent,
|
|
4869
5719
|
ParagraphComponent,
|
|
4870
5720
|
RootComponent,
|
|
@@ -4874,9 +5724,10 @@ function createXNote(host_1) {
|
|
|
4874
5724
|
TableComponent,
|
|
4875
5725
|
HighlightBoxComponent,
|
|
4876
5726
|
ListComponent,
|
|
4877
|
-
VideoComponent
|
|
4878
|
-
|
|
4879
|
-
|
|
5727
|
+
VideoComponent,
|
|
5728
|
+
AtComponent,
|
|
5729
|
+
KatexComponent
|
|
5730
|
+
], formatters: [
|
|
4880
5731
|
backgroundColorFormatter,
|
|
4881
5732
|
boldFormatter,
|
|
4882
5733
|
codeFormatter,
|
|
@@ -4887,18 +5738,14 @@ function createXNote(host_1) {
|
|
|
4887
5738
|
linkFormatter,
|
|
4888
5739
|
strikeThroughFormatter,
|
|
4889
5740
|
underlineFormatter
|
|
4890
|
-
],
|
|
4891
|
-
attributes: [
|
|
5741
|
+
], attributes: [
|
|
4892
5742
|
headingAttr,
|
|
4893
5743
|
textAlignAttr,
|
|
4894
5744
|
textIndentAttr
|
|
4895
|
-
],
|
|
4896
|
-
providers: [],
|
|
4897
|
-
plugins: [
|
|
5745
|
+
], plugins: [
|
|
4898
5746
|
new LeftToolbarPlugin(),
|
|
4899
5747
|
new ToolbarPlugin(),
|
|
4900
|
-
],
|
|
4901
|
-
onAfterStartup(textbus) {
|
|
5748
|
+
], onAfterStartup(textbus) {
|
|
4902
5749
|
registerBoldShortcut(textbus);
|
|
4903
5750
|
registerCodeShortcut(textbus);
|
|
4904
5751
|
registerItalicShortcut(textbus);
|
|
@@ -4907,34 +5754,52 @@ function createXNote(host_1) {
|
|
|
4907
5754
|
registerHeadingShortcut(textbus);
|
|
4908
5755
|
registerTextAlignShortcut(textbus);
|
|
4909
5756
|
registerTextIndentShortcut(textbus);
|
|
4910
|
-
|
|
4911
|
-
|
|
5757
|
+
registerAtShortcut(textbus);
|
|
5758
|
+
registerListShortcut(textbus);
|
|
5759
|
+
registerBlockquoteShortcut(textbus);
|
|
5760
|
+
} }, editorConfig));
|
|
5761
|
+
this.editorConfig = editorConfig;
|
|
5762
|
+
this.translator = new platformBrowser$1.OutputTranslator();
|
|
5763
|
+
this.vDomAdapter = vDomAdapter;
|
|
5764
|
+
}
|
|
5765
|
+
mount(host) {
|
|
5766
|
+
this.host = host;
|
|
4912
5767
|
let rootComp;
|
|
5768
|
+
const config = this.editorConfig;
|
|
4913
5769
|
if (config.content) {
|
|
4914
|
-
const parser =
|
|
5770
|
+
const parser = this.get(platformBrowser.Parser);
|
|
4915
5771
|
const doc = parser.parseDoc(config.content, rootComponentLoader);
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
5772
|
+
if (doc instanceof core$1.Component) {
|
|
5773
|
+
rootComp = doc;
|
|
5774
|
+
}
|
|
5775
|
+
else {
|
|
5776
|
+
const content = new core$1.Slot([
|
|
5777
|
+
core$1.ContentType.BlockComponent
|
|
5778
|
+
]);
|
|
5779
|
+
if (doc instanceof core$1.Slot) {
|
|
5780
|
+
deltaToBlock(doc.toDelta(), this).forEach(i => {
|
|
5781
|
+
content.insert(i);
|
|
5782
|
+
});
|
|
5783
|
+
}
|
|
5784
|
+
rootComp = new RootComponent(this, {
|
|
5785
|
+
content
|
|
5786
|
+
});
|
|
5787
|
+
}
|
|
4920
5788
|
}
|
|
4921
5789
|
else {
|
|
4922
|
-
rootComp = new RootComponent(
|
|
4923
|
-
|
|
4924
|
-
content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
|
|
5790
|
+
rootComp = new RootComponent(this, {
|
|
5791
|
+
content: new core$1.Slot([core$1.ContentType.BlockComponent])
|
|
4925
5792
|
});
|
|
4926
5793
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
return translator.transform(vDomAdapter.host);
|
|
4933
|
-
}
|
|
4934
|
-
};
|
|
4935
|
-
});
|
|
5794
|
+
return this.render(rootComp);
|
|
5795
|
+
}
|
|
5796
|
+
getHTML() {
|
|
5797
|
+
return this.translator.transform(this.vDomAdapter.host);
|
|
5798
|
+
}
|
|
4936
5799
|
}
|
|
4937
5800
|
|
|
5801
|
+
exports.AtComponent = AtComponent;
|
|
5802
|
+
exports.AtComponentView = AtComponentView;
|
|
4938
5803
|
exports.AttrTool = AttrTool;
|
|
4939
5804
|
exports.BlockTool = BlockTool;
|
|
4940
5805
|
exports.BlockquoteComponent = BlockquoteComponent;
|
|
@@ -4948,6 +5813,8 @@ exports.Divider = Divider;
|
|
|
4948
5813
|
exports.DragResize = DragResize;
|
|
4949
5814
|
exports.Dropdown = Dropdown;
|
|
4950
5815
|
exports.DropdownMenuPortal = DropdownMenuPortal;
|
|
5816
|
+
exports.Editor = Editor;
|
|
5817
|
+
exports.FileUploader = FileUploader;
|
|
4951
5818
|
exports.FontFamilyTool = FontFamilyTool;
|
|
4952
5819
|
exports.FontSizeTool = FontSizeTool;
|
|
4953
5820
|
exports.HighlightBoxComponent = HighlightBoxComponent;
|
|
@@ -4956,13 +5823,19 @@ exports.ImageComponent = ImageComponent;
|
|
|
4956
5823
|
exports.ImageView = ImageView;
|
|
4957
5824
|
exports.InsertTool = InsertTool;
|
|
4958
5825
|
exports.ItalicTool = ItalicTool;
|
|
5826
|
+
exports.KatexComponent = KatexComponent;
|
|
5827
|
+
exports.KatexComponentView = KatexComponentView;
|
|
5828
|
+
exports.Keymap = Keymap;
|
|
4959
5829
|
exports.LeftToolbar = LeftToolbar;
|
|
4960
5830
|
exports.LeftToolbarPlugin = LeftToolbarPlugin;
|
|
5831
|
+
exports.LinkJump = LinkJump;
|
|
4961
5832
|
exports.LinkTool = LinkTool;
|
|
4962
5833
|
exports.ListComponent = ListComponent;
|
|
4963
5834
|
exports.ListComponentView = ListComponentView;
|
|
4964
5835
|
exports.Matcher = Matcher;
|
|
5836
|
+
exports.MenuHeading = MenuHeading;
|
|
4965
5837
|
exports.MenuItem = MenuItem;
|
|
5838
|
+
exports.Organization = Organization;
|
|
4966
5839
|
exports.OutputInjectionToken = OutputInjectionToken;
|
|
4967
5840
|
exports.ParagraphComponent = ParagraphComponent;
|
|
4968
5841
|
exports.ParagraphView = ParagraphView;
|
|
@@ -4982,6 +5855,7 @@ exports.ToolbarPlugin = ToolbarPlugin;
|
|
|
4982
5855
|
exports.UnderlineTool = UnderlineTool;
|
|
4983
5856
|
exports.VideoComponent = VideoComponent;
|
|
4984
5857
|
exports.VideoView = VideoView;
|
|
5858
|
+
exports.atComponentLoader = atComponentLoader;
|
|
4985
5859
|
exports.autoComplete = autoComplete;
|
|
4986
5860
|
exports.backgroundColorFormatLoader = backgroundColorFormatLoader;
|
|
4987
5861
|
exports.backgroundColorFormatter = backgroundColorFormatter;
|
|
@@ -4992,7 +5866,6 @@ exports.codeFormatLoader = codeFormatLoader;
|
|
|
4992
5866
|
exports.codeFormatter = codeFormatter;
|
|
4993
5867
|
exports.colorFormatLoader = colorFormatLoader;
|
|
4994
5868
|
exports.colorFormatter = colorFormatter;
|
|
4995
|
-
exports.createXNote = createXNote;
|
|
4996
5869
|
exports.deltaToBlock = deltaToBlock;
|
|
4997
5870
|
exports.fontFamilyFormatLoader = fontFamilyFormatLoader;
|
|
4998
5871
|
exports.fontFamilyFormatter = fontFamilyFormatter;
|
|
@@ -5005,15 +5878,19 @@ exports.imageComponentLoader = imageComponentLoader;
|
|
|
5005
5878
|
exports.isSupportFont = isSupportFont;
|
|
5006
5879
|
exports.italicFormatLoader = italicFormatLoader;
|
|
5007
5880
|
exports.italicFormatter = italicFormatter;
|
|
5881
|
+
exports.katexComponentLoader = katexComponentLoader;
|
|
5008
5882
|
exports.languageList = languageList;
|
|
5009
5883
|
exports.linkFormatLoader = linkFormatLoader;
|
|
5010
5884
|
exports.linkFormatter = linkFormatter;
|
|
5011
5885
|
exports.listComponentLoader = listComponentLoader;
|
|
5012
5886
|
exports.paragraphComponentLoader = paragraphComponentLoader;
|
|
5887
|
+
exports.registerAtShortcut = registerAtShortcut;
|
|
5888
|
+
exports.registerBlockquoteShortcut = registerBlockquoteShortcut;
|
|
5013
5889
|
exports.registerBoldShortcut = registerBoldShortcut;
|
|
5014
5890
|
exports.registerCodeShortcut = registerCodeShortcut;
|
|
5015
5891
|
exports.registerHeadingShortcut = registerHeadingShortcut;
|
|
5016
5892
|
exports.registerItalicShortcut = registerItalicShortcut;
|
|
5893
|
+
exports.registerListShortcut = registerListShortcut;
|
|
5017
5894
|
exports.registerStrikeThroughShortcut = registerStrikeThroughShortcut;
|
|
5018
5895
|
exports.registerTextAlignShortcut = registerTextAlignShortcut;
|
|
5019
5896
|
exports.registerTextIndentShortcut = registerTextIndentShortcut;
|
|
@@ -5028,6 +5905,8 @@ exports.textAlignAttr = textAlignAttr;
|
|
|
5028
5905
|
exports.textAlignAttrLoader = textAlignAttrLoader;
|
|
5029
5906
|
exports.textIndentAttr = textIndentAttr;
|
|
5030
5907
|
exports.textIndentAttrLoader = textIndentAttrLoader;
|
|
5908
|
+
exports.toBlockquote = toBlockquote;
|
|
5909
|
+
exports.toList = toList;
|
|
5031
5910
|
exports.todolistComponentLoader = todolistComponentLoader;
|
|
5032
5911
|
exports.toggleBold = toggleBold;
|
|
5033
5912
|
exports.toggleCode = toggleCode;
|