@textbus/xnote 0.0.1-alpha.5 → 0.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/editor.d.ts +11 -6
- package/bundles/index.css +1 -1
- package/bundles/index.esm.css +1 -1
- package/bundles/index.esm.js +280 -268
- package/bundles/index.js +279 -267
- package/bundles/interfaces.d.ts +3 -0
- package/bundles/textbus/components/root/root.component.d.ts +0 -1
- package/package.json +6 -6
package/bundles/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var highlightjs = require('highlight.js');
|
|
|
11
11
|
var adapterViewfly = require('@textbus/adapter-viewfly');
|
|
12
12
|
var collaborate = require('@textbus/collaborate');
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var scopedId$k = "vf-69b4db";
|
|
15
15
|
|
|
16
16
|
/******************************************************************************
|
|
17
17
|
Copyright (c) Microsoft Corporation.
|
|
@@ -41,16 +41,6 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
41
41
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
42
42
|
}
|
|
43
43
|
|
|
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
44
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
45
|
var e = new Error(message);
|
|
56
46
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -142,7 +132,7 @@ function Button(props) {
|
|
|
142
132
|
subscription.unsubscribe();
|
|
143
133
|
});
|
|
144
134
|
}
|
|
145
|
-
return scopedCss.withScopedCSS(
|
|
135
|
+
return scopedCss.withScopedCSS(scopedId$k, () => {
|
|
146
136
|
return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
147
137
|
'btn',
|
|
148
138
|
{
|
|
@@ -154,10 +144,10 @@ function Button(props) {
|
|
|
154
144
|
});
|
|
155
145
|
}
|
|
156
146
|
|
|
157
|
-
var
|
|
147
|
+
var scopedId$j = "vf-ac7e8d";
|
|
158
148
|
|
|
159
149
|
function ComponentToolbar(props) {
|
|
160
|
-
return scopedCss.withScopedCSS(
|
|
150
|
+
return scopedCss.withScopedCSS(scopedId$j, () => {
|
|
161
151
|
return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
|
|
162
152
|
'toolbar',
|
|
163
153
|
{
|
|
@@ -167,15 +157,15 @@ function ComponentToolbar(props) {
|
|
|
167
157
|
});
|
|
168
158
|
}
|
|
169
159
|
|
|
170
|
-
var
|
|
160
|
+
var scopedId$i = "vf-ede279";
|
|
171
161
|
|
|
172
162
|
function Divider() {
|
|
173
|
-
return scopedCss.withScopedCSS(
|
|
163
|
+
return scopedCss.withScopedCSS(scopedId$i, () => {
|
|
174
164
|
return jsxRuntime.jsx("div", { class: "divider" });
|
|
175
165
|
});
|
|
176
166
|
}
|
|
177
167
|
|
|
178
|
-
var
|
|
168
|
+
var scopedId$h = "vf-4c1803";
|
|
179
169
|
|
|
180
170
|
function DragResize(props) {
|
|
181
171
|
const isShow = core.createSignal(false);
|
|
@@ -283,16 +273,16 @@ function DragResize(props) {
|
|
|
283
273
|
unUp.unsubscribe();
|
|
284
274
|
});
|
|
285
275
|
}
|
|
286
|
-
return scopedCss.withScopedCSS(
|
|
276
|
+
return scopedCss.withScopedCSS(scopedId$h, () => {
|
|
287
277
|
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
278
|
active: isShow()
|
|
289
279
|
}], children: [jsxRuntime.jsxs("div", { class: "mask", ref: mask, children: [component.state.width, "*", component.state.height] }), 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
280
|
});
|
|
291
281
|
}
|
|
292
282
|
|
|
293
|
-
var
|
|
283
|
+
var scopedId$g = "vf-a99c5e";
|
|
294
284
|
|
|
295
|
-
var
|
|
285
|
+
var scopedId$f = "vf-41a617";
|
|
296
286
|
|
|
297
287
|
const DropdownMenuPortal = core.withAnnotation({
|
|
298
288
|
providers: [
|
|
@@ -375,7 +365,7 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
375
365
|
dropdownContextService.canHide = true;
|
|
376
366
|
dropdownContextService.hide();
|
|
377
367
|
}
|
|
378
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
368
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$f, () => {
|
|
379
369
|
return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
|
|
380
370
|
width: props.width
|
|
381
371
|
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", children: props.children }) }));
|
|
@@ -438,7 +428,7 @@ const Dropdown = core.withAnnotation({
|
|
|
438
428
|
dropdownContextService.open();
|
|
439
429
|
}
|
|
440
430
|
},
|
|
441
|
-
$render: scopedCss.withScopedCSS(
|
|
431
|
+
$render: scopedCss.withScopedCSS(scopedId$g, () => {
|
|
442
432
|
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) ?
|
|
443
433
|
props.menu.map(menu => {
|
|
444
434
|
return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
|
|
@@ -454,7 +444,7 @@ const Dropdown = core.withAnnotation({
|
|
|
454
444
|
};
|
|
455
445
|
});
|
|
456
446
|
|
|
457
|
-
var
|
|
447
|
+
var scopedId$e = "vf-64f71d";
|
|
458
448
|
|
|
459
449
|
function MenuItem(props) {
|
|
460
450
|
const dropdownContextService = core.inject(exports.DropdownContextService, core.InjectFlags.Optional, null);
|
|
@@ -474,7 +464,7 @@ function MenuItem(props) {
|
|
|
474
464
|
}
|
|
475
465
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
|
|
476
466
|
}
|
|
477
|
-
return scopedCss.withScopedCSS(
|
|
467
|
+
return scopedCss.withScopedCSS(scopedId$e, () => {
|
|
478
468
|
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 ?
|
|
479
469
|
jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
|
|
480
470
|
jsxRuntime.jsx("div", { class: [
|
|
@@ -484,11 +474,11 @@ function MenuItem(props) {
|
|
|
484
474
|
});
|
|
485
475
|
}
|
|
486
476
|
|
|
487
|
-
var
|
|
477
|
+
var scopedId$d = "vf-a23c47";
|
|
488
478
|
|
|
489
479
|
function Popup(props) {
|
|
490
480
|
const host = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
491
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
481
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$d, () => {
|
|
492
482
|
return (jsxRuntime.jsx("div", { class: "popup", style: {
|
|
493
483
|
left: props.left + 'px',
|
|
494
484
|
top: props.top + 'px'
|
|
@@ -496,15 +486,15 @@ function Popup(props) {
|
|
|
496
486
|
}), host);
|
|
497
487
|
}
|
|
498
488
|
|
|
499
|
-
var
|
|
489
|
+
var scopedId$c = "vf-216815";
|
|
500
490
|
|
|
501
491
|
function ToolbarItem(props) {
|
|
502
|
-
return scopedCss.withScopedCSS(
|
|
492
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
503
493
|
return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
|
|
504
494
|
});
|
|
505
495
|
}
|
|
506
496
|
|
|
507
|
-
var
|
|
497
|
+
var scopedId$b = "vf-2a8a65";
|
|
508
498
|
|
|
509
499
|
exports.RefreshService = class RefreshService {
|
|
510
500
|
constructor() {
|
|
@@ -1333,7 +1323,7 @@ function AttrTool(props) {
|
|
|
1333
1323
|
break;
|
|
1334
1324
|
}
|
|
1335
1325
|
}
|
|
1336
|
-
return scopedCss.withScopedCSS(
|
|
1326
|
+
return scopedCss.withScopedCSS(scopedId$b, () => {
|
|
1337
1327
|
const states = checkStates();
|
|
1338
1328
|
return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1339
1329
|
{
|
|
@@ -1923,6 +1913,25 @@ class ListComponent extends core$1.Component {
|
|
|
1923
1913
|
selection.setPosition(slot, 0);
|
|
1924
1914
|
}
|
|
1925
1915
|
});
|
|
1916
|
+
core$1.useDynamicShortcut({
|
|
1917
|
+
keymap: {
|
|
1918
|
+
key: 'Tab'
|
|
1919
|
+
},
|
|
1920
|
+
action: () => {
|
|
1921
|
+
updateAfterList(this);
|
|
1922
|
+
return false;
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
core$1.useDynamicShortcut({
|
|
1926
|
+
keymap: {
|
|
1927
|
+
key: 'Tab',
|
|
1928
|
+
shiftKey: true
|
|
1929
|
+
},
|
|
1930
|
+
action: () => {
|
|
1931
|
+
Promise.resolve().then(() => updateAfterList(this));
|
|
1932
|
+
return false;
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1926
1935
|
}
|
|
1927
1936
|
}
|
|
1928
1937
|
ListComponent.componentName = 'ListComponent';
|
|
@@ -2236,17 +2245,16 @@ function useBlockTransform() {
|
|
|
2236
2245
|
commander.unApplyAttribute(headingAttr);
|
|
2237
2246
|
commander.transform({
|
|
2238
2247
|
targetType: ParagraphComponent.type,
|
|
2239
|
-
multipleSlot: false,
|
|
2240
2248
|
slotFactory() {
|
|
2241
2249
|
return new core$1.Slot([
|
|
2242
2250
|
core$1.ContentType.InlineComponent,
|
|
2243
2251
|
core$1.ContentType.Text
|
|
2244
2252
|
]);
|
|
2245
2253
|
},
|
|
2246
|
-
stateFactory(
|
|
2247
|
-
return new ParagraphComponent(textbus, {
|
|
2254
|
+
stateFactory(slots) {
|
|
2255
|
+
return slots.map(slot => new ParagraphComponent(textbus, {
|
|
2248
2256
|
slot
|
|
2249
|
-
});
|
|
2257
|
+
}));
|
|
2250
2258
|
}
|
|
2251
2259
|
});
|
|
2252
2260
|
break;
|
|
@@ -2265,17 +2273,18 @@ function useBlockTransform() {
|
|
|
2265
2273
|
commander.unApplyAttribute(headingAttr);
|
|
2266
2274
|
commander.transform({
|
|
2267
2275
|
targetType: TodolistComponent.type,
|
|
2268
|
-
multipleSlot: false,
|
|
2269
2276
|
slotFactory() {
|
|
2270
2277
|
return new core$1.Slot([
|
|
2271
2278
|
core$1.ContentType.InlineComponent,
|
|
2272
2279
|
core$1.ContentType.Text
|
|
2273
2280
|
]);
|
|
2274
2281
|
},
|
|
2275
|
-
stateFactory(
|
|
2276
|
-
return
|
|
2277
|
-
|
|
2278
|
-
|
|
2282
|
+
stateFactory(slots) {
|
|
2283
|
+
return slots.map(slot => {
|
|
2284
|
+
return new TodolistComponent(textbus, {
|
|
2285
|
+
checked: false,
|
|
2286
|
+
slot
|
|
2287
|
+
});
|
|
2279
2288
|
});
|
|
2280
2289
|
}
|
|
2281
2290
|
});
|
|
@@ -2285,18 +2294,19 @@ function useBlockTransform() {
|
|
|
2285
2294
|
{
|
|
2286
2295
|
commander.transform({
|
|
2287
2296
|
targetType: ListComponent.type,
|
|
2288
|
-
multipleSlot: false,
|
|
2289
2297
|
slotFactory() {
|
|
2290
2298
|
return new core$1.Slot([
|
|
2291
2299
|
core$1.ContentType.InlineComponent,
|
|
2292
2300
|
core$1.ContentType.Text
|
|
2293
2301
|
]);
|
|
2294
2302
|
},
|
|
2295
|
-
stateFactory(
|
|
2296
|
-
return
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2303
|
+
stateFactory(slots) {
|
|
2304
|
+
return slots.map((slot, index) => {
|
|
2305
|
+
return new ListComponent(textbus, {
|
|
2306
|
+
type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
|
|
2307
|
+
reorder: index === 0,
|
|
2308
|
+
slot
|
|
2309
|
+
});
|
|
2300
2310
|
});
|
|
2301
2311
|
}
|
|
2302
2312
|
});
|
|
@@ -2344,16 +2354,17 @@ function useBlockTransform() {
|
|
|
2344
2354
|
if (state.state === core$1.QueryStateType.Enabled) {
|
|
2345
2355
|
commander.transform({
|
|
2346
2356
|
targetType: ParagraphComponent.type,
|
|
2347
|
-
multipleSlot: false,
|
|
2348
2357
|
slotFactory() {
|
|
2349
2358
|
return new core$1.Slot([
|
|
2350
2359
|
core$1.ContentType.InlineComponent,
|
|
2351
2360
|
core$1.ContentType.Text
|
|
2352
2361
|
]);
|
|
2353
2362
|
},
|
|
2354
|
-
stateFactory(
|
|
2355
|
-
return
|
|
2356
|
-
|
|
2363
|
+
stateFactory(slots) {
|
|
2364
|
+
return slots.map(slot => {
|
|
2365
|
+
return new ParagraphComponent(textbus, {
|
|
2366
|
+
slot
|
|
2367
|
+
});
|
|
2357
2368
|
});
|
|
2358
2369
|
}
|
|
2359
2370
|
});
|
|
@@ -2361,24 +2372,23 @@ function useBlockTransform() {
|
|
|
2361
2372
|
else {
|
|
2362
2373
|
commander.transform({
|
|
2363
2374
|
targetType: SourceCodeComponent.type,
|
|
2364
|
-
multipleSlot: true,
|
|
2365
2375
|
slotFactory() {
|
|
2366
2376
|
return new core$1.Slot([
|
|
2367
2377
|
core$1.ContentType.Text
|
|
2368
2378
|
]);
|
|
2369
2379
|
},
|
|
2370
2380
|
stateFactory(slots) {
|
|
2371
|
-
return new SourceCodeComponent(textbus, {
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2381
|
+
return [new SourceCodeComponent(textbus, {
|
|
2382
|
+
lang: '',
|
|
2383
|
+
lineNumber: true,
|
|
2384
|
+
autoBreak: true,
|
|
2385
|
+
slots: slots.map(slot => {
|
|
2386
|
+
return {
|
|
2387
|
+
slot,
|
|
2388
|
+
emphasize: false
|
|
2389
|
+
};
|
|
2390
|
+
})
|
|
2391
|
+
})];
|
|
2382
2392
|
}
|
|
2383
2393
|
});
|
|
2384
2394
|
}
|
|
@@ -2427,7 +2437,7 @@ function useBlockTransform() {
|
|
|
2427
2437
|
function BlockTool() {
|
|
2428
2438
|
const checkStates = useActiveBlock();
|
|
2429
2439
|
const transform = useBlockTransform();
|
|
2430
|
-
return scopedCss.withScopedCSS(
|
|
2440
|
+
return scopedCss.withScopedCSS(scopedId$b, () => {
|
|
2431
2441
|
const states = checkStates();
|
|
2432
2442
|
const types = [
|
|
2433
2443
|
[states.paragraph, 'xnote-icon-pilcrow'],
|
|
@@ -2858,7 +2868,7 @@ function CodeTool() {
|
|
|
2858
2868
|
};
|
|
2859
2869
|
}
|
|
2860
2870
|
|
|
2861
|
-
var
|
|
2871
|
+
var scopedId$a = "vf-1fbbdf";
|
|
2862
2872
|
|
|
2863
2873
|
function ColorTool(props) {
|
|
2864
2874
|
const query = core.inject(core$1.Query);
|
|
@@ -2906,7 +2916,7 @@ function ColorTool(props) {
|
|
|
2906
2916
|
'#90a0e5',
|
|
2907
2917
|
'#c596e0',
|
|
2908
2918
|
];
|
|
2909
|
-
return scopedCss.withScopedCSS(
|
|
2919
|
+
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
2910
2920
|
const vm = viewModel();
|
|
2911
2921
|
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: {
|
|
2912
2922
|
active: textColor() === ''
|
|
@@ -3114,7 +3124,7 @@ function ItalicTool() {
|
|
|
3114
3124
|
};
|
|
3115
3125
|
}
|
|
3116
3126
|
|
|
3117
|
-
var
|
|
3127
|
+
var scopedId$9 = "vf-269a0b";
|
|
3118
3128
|
|
|
3119
3129
|
function LinkTool(props) {
|
|
3120
3130
|
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
@@ -3145,7 +3155,7 @@ function LinkTool(props) {
|
|
|
3145
3155
|
core.onUnmounted(() => {
|
|
3146
3156
|
sub.unsubscribe();
|
|
3147
3157
|
});
|
|
3148
|
-
return scopedCss.withScopedCSS(
|
|
3158
|
+
return scopedCss.withScopedCSS(scopedId$9, () => {
|
|
3149
3159
|
const containerRect = container.getBoundingClientRect();
|
|
3150
3160
|
const rect = isShow() ? selectionBridge.getRect({
|
|
3151
3161
|
slot: selection.focusSlot,
|
|
@@ -3214,12 +3224,93 @@ function UnderlineTool() {
|
|
|
3214
3224
|
};
|
|
3215
3225
|
}
|
|
3216
3226
|
|
|
3217
|
-
var
|
|
3227
|
+
var scopedId$8 = "vf-cf8e1c";
|
|
3228
|
+
|
|
3229
|
+
class FileUploader {
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
class ImageComponent extends core$1.Component {
|
|
3233
|
+
static fromJSON(textbus, json) {
|
|
3234
|
+
return new ImageComponent(textbus, Object.assign({}, json));
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
3238
|
+
ImageComponent.componentName = 'ImageComponent';
|
|
3239
|
+
function ImageView(props) {
|
|
3240
|
+
const { name, state } = props.component;
|
|
3241
|
+
const imageRef = core.createRef();
|
|
3242
|
+
const readonly = useReadonly();
|
|
3243
|
+
const output = useOutput();
|
|
3244
|
+
return () => {
|
|
3245
|
+
if (readonly() || output()) {
|
|
3246
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
3247
|
+
width: state.width,
|
|
3248
|
+
height: state.height
|
|
3249
|
+
} }) }));
|
|
3250
|
+
}
|
|
3251
|
+
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: {
|
|
3252
|
+
width: state.width,
|
|
3253
|
+
height: state.height
|
|
3254
|
+
} }) }) }));
|
|
3255
|
+
};
|
|
3256
|
+
}
|
|
3257
|
+
const imageComponentLoader = {
|
|
3258
|
+
match(element) {
|
|
3259
|
+
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
3260
|
+
},
|
|
3261
|
+
read(element, textbus) {
|
|
3262
|
+
var _a;
|
|
3263
|
+
return new ImageComponent(textbus, {
|
|
3264
|
+
src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('img')) === null || _a === void 0 ? void 0 : _a.src) || ''
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
|
|
3269
|
+
class VideoComponent extends core$1.Component {
|
|
3270
|
+
static fromJSON(textbus, json) {
|
|
3271
|
+
return new VideoComponent(textbus, Object.assign({}, json));
|
|
3272
|
+
}
|
|
3273
|
+
setup() {
|
|
3274
|
+
//
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
VideoComponent.type = core$1.ContentType.InlineComponent;
|
|
3278
|
+
VideoComponent.componentName = 'VideoComponent';
|
|
3279
|
+
function VideoView(props) {
|
|
3280
|
+
const { name, state } = props.component;
|
|
3281
|
+
const videoRef = core.createRef();
|
|
3282
|
+
const readonly = useReadonly();
|
|
3283
|
+
const output = useOutput();
|
|
3284
|
+
return () => {
|
|
3285
|
+
if (readonly() || output()) {
|
|
3286
|
+
return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
|
|
3287
|
+
width: state.width,
|
|
3288
|
+
height: state.height
|
|
3289
|
+
} }) }));
|
|
3290
|
+
}
|
|
3291
|
+
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: {
|
|
3292
|
+
width: state.width,
|
|
3293
|
+
height: state.height
|
|
3294
|
+
} }) }) }));
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
const videoComponentLoader = {
|
|
3298
|
+
match(element) {
|
|
3299
|
+
return element.tagName === 'IMG' || element.dataset.component === VideoComponent.componentName;
|
|
3300
|
+
},
|
|
3301
|
+
read(element, textbus) {
|
|
3302
|
+
var _a;
|
|
3303
|
+
return new VideoComponent(textbus, {
|
|
3304
|
+
src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('video')) === null || _a === void 0 ? void 0 : _a.src) || ''
|
|
3305
|
+
});
|
|
3306
|
+
}
|
|
3307
|
+
};
|
|
3218
3308
|
|
|
3219
3309
|
function InsertTool(props) {
|
|
3220
3310
|
const commander = core.inject(core$1.Commander);
|
|
3221
3311
|
const selection = core.inject(core$1.Selection);
|
|
3222
3312
|
const textbus = core.inject(core$1.Textbus);
|
|
3313
|
+
const fileUploader = core.inject(FileUploader, core.InjectFlags.Optional, null);
|
|
3223
3314
|
function insert(type) {
|
|
3224
3315
|
var _a;
|
|
3225
3316
|
const component = (_a = props.slot) === null || _a === void 0 ? void 0 : _a.parent;
|
|
@@ -3312,8 +3403,24 @@ function InsertTool(props) {
|
|
|
3312
3403
|
}
|
|
3313
3404
|
break;
|
|
3314
3405
|
case 'image':
|
|
3406
|
+
if (fileUploader) {
|
|
3407
|
+
Promise.resolve(fileUploader.uploadFile('image')).then(url => {
|
|
3408
|
+
const img = new ImageComponent(textbus, {
|
|
3409
|
+
src: url
|
|
3410
|
+
});
|
|
3411
|
+
commander.insert(img);
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3315
3414
|
break;
|
|
3316
3415
|
case 'video':
|
|
3416
|
+
if (fileUploader) {
|
|
3417
|
+
Promise.resolve(fileUploader.uploadFile('video')).then(url => {
|
|
3418
|
+
const img = new VideoComponent(textbus, {
|
|
3419
|
+
src: url
|
|
3420
|
+
});
|
|
3421
|
+
commander.insert(img);
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3317
3424
|
break;
|
|
3318
3425
|
case 'highlightBox':
|
|
3319
3426
|
{
|
|
@@ -3326,12 +3433,12 @@ function InsertTool(props) {
|
|
|
3326
3433
|
break;
|
|
3327
3434
|
}
|
|
3328
3435
|
}
|
|
3329
|
-
return scopedCss.withScopedCSS(
|
|
3436
|
+
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
3330
3437
|
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-warning" }), children: "\u9AD8\u4EAE\u5757" })] });
|
|
3331
3438
|
});
|
|
3332
3439
|
}
|
|
3333
3440
|
|
|
3334
|
-
var
|
|
3441
|
+
var scopedId$7 = "vf-b05292";
|
|
3335
3442
|
|
|
3336
3443
|
const LeftToolbar = core.withAnnotation({
|
|
3337
3444
|
providers: [exports.RefreshService]
|
|
@@ -3494,7 +3601,7 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3494
3601
|
function changeIgnoreMove(b) {
|
|
3495
3602
|
isIgnoreMove = b;
|
|
3496
3603
|
}
|
|
3497
|
-
return scopedCss.withScopedCSS(
|
|
3604
|
+
return scopedCss.withScopedCSS(scopedId$7, () => {
|
|
3498
3605
|
const position = positionSignal();
|
|
3499
3606
|
const slot = activeSlot();
|
|
3500
3607
|
let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
|
|
@@ -3568,7 +3675,7 @@ class LeftToolbarPlugin {
|
|
|
3568
3675
|
}
|
|
3569
3676
|
}
|
|
3570
3677
|
|
|
3571
|
-
var
|
|
3678
|
+
var scopedId$6 = "vf-fee98b";
|
|
3572
3679
|
|
|
3573
3680
|
exports.EditorService = class EditorService {
|
|
3574
3681
|
constructor() {
|
|
@@ -3678,7 +3785,7 @@ const Toolbar = core.withAnnotation({
|
|
|
3678
3785
|
mousedownSubscription.unsubscribe();
|
|
3679
3786
|
mouseupSubscription.unsubscribe();
|
|
3680
3787
|
});
|
|
3681
|
-
return scopedCss.withScopedCSS(
|
|
3788
|
+
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
3682
3789
|
const p = viewPosition();
|
|
3683
3790
|
return (jsxRuntime.jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
|
|
3684
3791
|
left: p.left + 'px',
|
|
@@ -3813,72 +3920,35 @@ class Matcher {
|
|
|
3813
3920
|
}
|
|
3814
3921
|
}
|
|
3815
3922
|
|
|
3816
|
-
class ImageComponent extends core$1.Component {
|
|
3817
|
-
static fromJSON(textbus, json) {
|
|
3818
|
-
return new ImageComponent(textbus, Object.assign({}, json));
|
|
3819
|
-
}
|
|
3820
|
-
}
|
|
3821
|
-
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
3822
|
-
ImageComponent.componentName = 'ImageComponent';
|
|
3823
|
-
function ImageView(props) {
|
|
3824
|
-
const { name, state } = props.component;
|
|
3825
|
-
const imageRef = core.createRef();
|
|
3826
|
-
const readonly = useReadonly();
|
|
3827
|
-
const output = useOutput();
|
|
3828
|
-
return () => {
|
|
3829
|
-
if (readonly() || output()) {
|
|
3830
|
-
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
3831
|
-
width: state.width,
|
|
3832
|
-
height: state.height
|
|
3833
|
-
} }) }));
|
|
3834
|
-
}
|
|
3835
|
-
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: {
|
|
3836
|
-
width: state.width,
|
|
3837
|
-
height: state.height
|
|
3838
|
-
} }) }) }));
|
|
3839
|
-
};
|
|
3840
|
-
}
|
|
3841
|
-
const imageComponentLoader = {
|
|
3842
|
-
match(element) {
|
|
3843
|
-
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
3844
|
-
},
|
|
3845
|
-
read(element, textbus) {
|
|
3846
|
-
var _a;
|
|
3847
|
-
return new ImageComponent(textbus, {
|
|
3848
|
-
src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('img')) === null || _a === void 0 ? void 0 : _a.src) || ''
|
|
3849
|
-
});
|
|
3850
|
-
}
|
|
3851
|
-
};
|
|
3852
|
-
|
|
3853
3923
|
class RootComponent extends core$1.Component {
|
|
3854
3924
|
constructor() {
|
|
3855
3925
|
super(...arguments);
|
|
3856
3926
|
this.onCompositionStart = new core$1.Subject();
|
|
3857
3927
|
}
|
|
3858
3928
|
static fromJSON(textbus, json) {
|
|
3859
|
-
const heading = textbus.get(
|
|
3929
|
+
// const heading = textbus.get(Registry).createSlot(json.heading)
|
|
3860
3930
|
const content = textbus.get(core$1.Registry).createSlot(json.content);
|
|
3861
3931
|
return new RootComponent(textbus, {
|
|
3862
|
-
heading,
|
|
3932
|
+
// heading,
|
|
3863
3933
|
content
|
|
3864
3934
|
});
|
|
3865
3935
|
}
|
|
3866
3936
|
setup() {
|
|
3867
|
-
const textbus =
|
|
3868
|
-
const selection = textbus.get(
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
})
|
|
3937
|
+
// const textbus = useContext()
|
|
3938
|
+
// const selection = textbus.get(Selection)
|
|
3939
|
+
// onBreak(ev => {
|
|
3940
|
+
// if (ev.target === this.state.heading) {
|
|
3941
|
+
// const afterContent = ev.target.cut(ev.data.index)
|
|
3942
|
+
// const p = new ParagraphComponent(textbus, {
|
|
3943
|
+
// slot: afterContent
|
|
3944
|
+
// })
|
|
3945
|
+
// const body = this.state.content
|
|
3946
|
+
// body.retain(0)
|
|
3947
|
+
// body.insert(p)
|
|
3948
|
+
// selection.setPosition(afterContent, 0)
|
|
3949
|
+
// ev.preventDefault()
|
|
3950
|
+
// }
|
|
3951
|
+
// })
|
|
3882
3952
|
useBlockContent(this.state.content);
|
|
3883
3953
|
core$1.onCompositionStart(ev => {
|
|
3884
3954
|
this.onCompositionStart.next(ev);
|
|
@@ -3900,37 +3970,27 @@ RootComponent.componentName = 'RootComponent';
|
|
|
3900
3970
|
RootComponent.type = core$1.ContentType.BlockComponent;
|
|
3901
3971
|
function RootView(props) {
|
|
3902
3972
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
3903
|
-
const {
|
|
3973
|
+
const { content } = props.component.state;
|
|
3904
3974
|
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
|
-
}
|
|
3975
|
+
const sub = props.component.onCompositionStart.subscribe(() => {
|
|
3976
|
+
node.children[0].dataset.placeholder = '';
|
|
3912
3977
|
});
|
|
3913
3978
|
return () => {
|
|
3914
3979
|
sub.unsubscribe();
|
|
3915
3980
|
};
|
|
3916
3981
|
});
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
})
|
|
3982
|
+
// onUpdated(() => {
|
|
3983
|
+
// props.component.afterCheck()
|
|
3984
|
+
// })
|
|
3920
3985
|
const readonly = useReadonly();
|
|
3921
3986
|
return () => {
|
|
3922
3987
|
const { rootRef } = props;
|
|
3923
|
-
return (jsxRuntime.
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
return (core$1.createVNode('div', {
|
|
3930
|
-
class: 'xnote-content',
|
|
3931
|
-
'data-placeholder': content.isEmpty ? '请输入内容' : ''
|
|
3932
|
-
}, children));
|
|
3933
|
-
}, readonly())] }));
|
|
3988
|
+
return (jsxRuntime.jsx("div", { class: "xnote-root", ref: [rootRef, ref], children: adapter.slotRender(content, children => {
|
|
3989
|
+
return (core$1.createVNode('div', {
|
|
3990
|
+
class: 'xnote-content',
|
|
3991
|
+
'data-placeholder': content.isEmpty ? '请输入内容' : ''
|
|
3992
|
+
}, children));
|
|
3993
|
+
}, readonly()) }));
|
|
3934
3994
|
};
|
|
3935
3995
|
}
|
|
3936
3996
|
const rootComponentLoader = {
|
|
@@ -3955,7 +4015,7 @@ const rootComponentLoader = {
|
|
|
3955
4015
|
}
|
|
3956
4016
|
};
|
|
3957
4017
|
|
|
3958
|
-
var
|
|
4018
|
+
var scopedId$5 = "vf-681de2";
|
|
3959
4019
|
|
|
3960
4020
|
let TableService = class TableService {
|
|
3961
4021
|
constructor() {
|
|
@@ -4042,12 +4102,12 @@ function ResizeColumn(props) {
|
|
|
4042
4102
|
});
|
|
4043
4103
|
return () => sub.unsubscribe();
|
|
4044
4104
|
});
|
|
4045
|
-
return scopedCss.withScopedCSS(
|
|
4105
|
+
return scopedCss.withScopedCSS(scopedId$5, () => {
|
|
4046
4106
|
return jsxRuntime.jsx("div", { ref: dragLineRef, class: ['drag-line'] });
|
|
4047
4107
|
});
|
|
4048
4108
|
}
|
|
4049
4109
|
|
|
4050
|
-
var
|
|
4110
|
+
var scopedId$4 = "vf-d64cf9";
|
|
4051
4111
|
|
|
4052
4112
|
function TopBar(props) {
|
|
4053
4113
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4115,7 +4175,7 @@ function TopBar(props) {
|
|
|
4115
4175
|
s.unsubscribe();
|
|
4116
4176
|
});
|
|
4117
4177
|
const deleteIndex = core.createSignal(null);
|
|
4118
|
-
return scopedCss.withScopedCSS(
|
|
4178
|
+
return scopedCss.withScopedCSS(scopedId$4, () => {
|
|
4119
4179
|
const { state, tableSelection } = props.component;
|
|
4120
4180
|
const position = tableSelection();
|
|
4121
4181
|
return (jsxRuntime.jsx("div", { class: ['top-bar', {
|
|
@@ -4168,7 +4228,7 @@ function TopBar(props) {
|
|
|
4168
4228
|
});
|
|
4169
4229
|
}
|
|
4170
4230
|
|
|
4171
|
-
var
|
|
4231
|
+
var scopedId$3 = "vf-b1149b";
|
|
4172
4232
|
|
|
4173
4233
|
function Scroll(props) {
|
|
4174
4234
|
const scrollRef = core.createRef();
|
|
@@ -4200,7 +4260,7 @@ function Scroll(props) {
|
|
|
4200
4260
|
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
4201
4261
|
});
|
|
4202
4262
|
});
|
|
4203
|
-
return scopedCss.withScopedCSS(
|
|
4263
|
+
return scopedCss.withScopedCSS(scopedId$3, () => {
|
|
4204
4264
|
return jsxRuntime.jsx("div", { ref: [scrollRef, props.scrollRef], class: ['scroll-container', {
|
|
4205
4265
|
'left-end': showShadow().leftEnd,
|
|
4206
4266
|
'right-end': showShadow().rightEnd,
|
|
@@ -4212,7 +4272,7 @@ function Scroll(props) {
|
|
|
4212
4272
|
});
|
|
4213
4273
|
}
|
|
4214
4274
|
|
|
4215
|
-
var
|
|
4275
|
+
var scopedId$2 = "vf-ef93c0";
|
|
4216
4276
|
|
|
4217
4277
|
function LeftBar(props) {
|
|
4218
4278
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4286,7 +4346,7 @@ function LeftBar(props) {
|
|
|
4286
4346
|
textbus.focus();
|
|
4287
4347
|
});
|
|
4288
4348
|
}
|
|
4289
|
-
return scopedCss.withScopedCSS(
|
|
4349
|
+
return scopedCss.withScopedCSS(scopedId$2, () => {
|
|
4290
4350
|
const { state, tableSelection } = props.component;
|
|
4291
4351
|
const position = tableSelection();
|
|
4292
4352
|
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 +4394,7 @@ function LeftBar(props) {
|
|
|
4334
4394
|
});
|
|
4335
4395
|
}
|
|
4336
4396
|
|
|
4337
|
-
var
|
|
4397
|
+
var scopedId$1 = "vf-d4c4a9";
|
|
4338
4398
|
|
|
4339
4399
|
function sum(numbers) {
|
|
4340
4400
|
return numbers.reduce((a, b) => a + b, 0);
|
|
@@ -4367,7 +4427,7 @@ function ResizeRow(props) {
|
|
|
4367
4427
|
});
|
|
4368
4428
|
return () => sub.unsubscribe();
|
|
4369
4429
|
});
|
|
4370
|
-
return scopedCss.withScopedCSS(
|
|
4430
|
+
return scopedCss.withScopedCSS(scopedId$1, () => {
|
|
4371
4431
|
return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
|
|
4372
4432
|
display: styles().visible ? 'block' : 'none',
|
|
4373
4433
|
top: styles().top + 'px',
|
|
@@ -4376,7 +4436,7 @@ function ResizeRow(props) {
|
|
|
4376
4436
|
});
|
|
4377
4437
|
}
|
|
4378
4438
|
|
|
4379
|
-
var
|
|
4439
|
+
var scopedId = "vf-4a5ad1";
|
|
4380
4440
|
|
|
4381
4441
|
function SelectionMask(props) {
|
|
4382
4442
|
const [styles, updateStyles] = hooks.useProduce({
|
|
@@ -4429,7 +4489,7 @@ function SelectionMask(props) {
|
|
|
4429
4489
|
core.onUnmounted(() => {
|
|
4430
4490
|
s.unsubscribe();
|
|
4431
4491
|
});
|
|
4432
|
-
return scopedCss.withScopedCSS(
|
|
4492
|
+
return scopedCss.withScopedCSS(scopedId, () => {
|
|
4433
4493
|
const style = styles();
|
|
4434
4494
|
return (jsxRuntime.jsx("div", { class: "mask", style: {
|
|
4435
4495
|
display: style.visible ? 'block' : 'none',
|
|
@@ -4727,48 +4787,8 @@ function autoComplete(table) {
|
|
|
4727
4787
|
});
|
|
4728
4788
|
}
|
|
4729
4789
|
|
|
4730
|
-
class
|
|
4731
|
-
|
|
4732
|
-
return new VideoComponent(textbus, Object.assign({}, json));
|
|
4733
|
-
}
|
|
4734
|
-
setup() {
|
|
4735
|
-
//
|
|
4736
|
-
}
|
|
4737
|
-
}
|
|
4738
|
-
VideoComponent.type = core$1.ContentType.InlineComponent;
|
|
4739
|
-
VideoComponent.componentName = 'VideoComponent';
|
|
4740
|
-
function VideoView(props) {
|
|
4741
|
-
const { name, state } = props.component;
|
|
4742
|
-
const videoRef = core.createRef();
|
|
4743
|
-
const readonly = useReadonly();
|
|
4744
|
-
const output = useOutput();
|
|
4745
|
-
return () => {
|
|
4746
|
-
if (readonly() || output()) {
|
|
4747
|
-
return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
|
|
4748
|
-
width: state.width,
|
|
4749
|
-
height: state.height
|
|
4750
|
-
} }) }));
|
|
4751
|
-
}
|
|
4752
|
-
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: {
|
|
4753
|
-
width: state.width,
|
|
4754
|
-
height: state.height
|
|
4755
|
-
} }) }) }));
|
|
4756
|
-
};
|
|
4757
|
-
}
|
|
4758
|
-
const videoComponentLoader = {
|
|
4759
|
-
match(element) {
|
|
4760
|
-
return element.tagName === 'IMG' || element.dataset.component === VideoComponent.componentName;
|
|
4761
|
-
},
|
|
4762
|
-
read(element, textbus) {
|
|
4763
|
-
var _a;
|
|
4764
|
-
return new VideoComponent(textbus, {
|
|
4765
|
-
src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('video')) === null || _a === void 0 ? void 0 : _a.src) || ''
|
|
4766
|
-
});
|
|
4767
|
-
}
|
|
4768
|
-
};
|
|
4769
|
-
|
|
4770
|
-
function createXNote(host_1) {
|
|
4771
|
-
return __awaiter(this, arguments, void 0, function* (host, config = {}) {
|
|
4790
|
+
class Editor extends core$1.Textbus {
|
|
4791
|
+
constructor(editorConfig) {
|
|
4772
4792
|
const adapter = new adapterViewfly.ViewflyAdapter({
|
|
4773
4793
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
4774
4794
|
[RootComponent.componentName]: RootView,
|
|
@@ -4792,38 +4812,9 @@ function createXNote(host_1) {
|
|
|
4792
4812
|
app.destroy();
|
|
4793
4813
|
};
|
|
4794
4814
|
});
|
|
4795
|
-
const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
|
|
4796
|
-
[ParagraphComponent.componentName]: ParagraphView,
|
|
4797
|
-
[RootComponent.componentName]: RootView,
|
|
4798
|
-
[BlockquoteComponent.componentName]: BlockquoteView,
|
|
4799
|
-
[TodolistComponent.componentName]: TodolistView,
|
|
4800
|
-
[SourceCodeComponent.componentName]: SourceCodeView,
|
|
4801
|
-
[TableComponent.componentName]: TableComponentView,
|
|
4802
|
-
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4803
|
-
[ListComponent.componentName]: ListComponentView,
|
|
4804
|
-
[ImageComponent.componentName]: ImageView,
|
|
4805
|
-
[VideoComponent.componentName]: VideoView
|
|
4806
|
-
}, (host, root, injector) => {
|
|
4807
|
-
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4808
|
-
provide: OutputInjectionToken,
|
|
4809
|
-
useValue: true
|
|
4810
|
-
}, {
|
|
4811
|
-
provide: platformBrowser.DomAdapter,
|
|
4812
|
-
useFactory() {
|
|
4813
|
-
return vDomAdapter;
|
|
4814
|
-
}
|
|
4815
|
-
}]);
|
|
4816
|
-
const app = platformBrowser$1.createApp(root, {
|
|
4817
|
-
context: appInjector,
|
|
4818
|
-
nativeRenderer: new platformBrowser$1.HTMLRenderer()
|
|
4819
|
-
}).mount(host);
|
|
4820
|
-
return () => {
|
|
4821
|
-
app.destroy();
|
|
4822
|
-
};
|
|
4823
|
-
});
|
|
4824
4815
|
const browserModule = new platformBrowser.BrowserModule({
|
|
4825
|
-
renderTo() {
|
|
4826
|
-
return host;
|
|
4816
|
+
renderTo: () => {
|
|
4817
|
+
return this.host;
|
|
4827
4818
|
},
|
|
4828
4819
|
adapter,
|
|
4829
4820
|
componentLoaders: [
|
|
@@ -4856,15 +4847,39 @@ function createXNote(host_1) {
|
|
|
4856
4847
|
]
|
|
4857
4848
|
});
|
|
4858
4849
|
const modules = [browserModule];
|
|
4859
|
-
if (
|
|
4860
|
-
modules.push(new collaborate.CollaborateModule(
|
|
4850
|
+
if (editorConfig.collaborateConfig) {
|
|
4851
|
+
modules.push(new collaborate.CollaborateModule(editorConfig.collaborateConfig));
|
|
4861
4852
|
}
|
|
4862
|
-
const
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4853
|
+
const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
|
|
4854
|
+
[ParagraphComponent.componentName]: ParagraphView,
|
|
4855
|
+
[RootComponent.componentName]: RootView,
|
|
4856
|
+
[BlockquoteComponent.componentName]: BlockquoteView,
|
|
4857
|
+
[TodolistComponent.componentName]: TodolistView,
|
|
4858
|
+
[SourceCodeComponent.componentName]: SourceCodeView,
|
|
4859
|
+
[TableComponent.componentName]: TableComponentView,
|
|
4860
|
+
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4861
|
+
[ListComponent.componentName]: ListComponentView,
|
|
4862
|
+
[ImageComponent.componentName]: ImageView,
|
|
4863
|
+
[VideoComponent.componentName]: VideoView
|
|
4864
|
+
}, (host, root, injector) => {
|
|
4865
|
+
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4866
|
+
provide: OutputInjectionToken,
|
|
4867
|
+
useValue: true
|
|
4868
|
+
}, {
|
|
4869
|
+
provide: platformBrowser.DomAdapter,
|
|
4870
|
+
useFactory: () => {
|
|
4871
|
+
return vDomAdapter;
|
|
4872
|
+
}
|
|
4873
|
+
}]);
|
|
4874
|
+
const app = platformBrowser$1.createApp(root, {
|
|
4875
|
+
context: appInjector,
|
|
4876
|
+
nativeRenderer: new platformBrowser$1.HTMLRenderer()
|
|
4877
|
+
}).mount(host);
|
|
4878
|
+
return () => {
|
|
4879
|
+
app.destroy();
|
|
4880
|
+
};
|
|
4881
|
+
});
|
|
4882
|
+
super(Object.assign({ additionalAdapters: [vDomAdapter], imports: modules, components: [
|
|
4868
4883
|
ImageComponent,
|
|
4869
4884
|
ParagraphComponent,
|
|
4870
4885
|
RootComponent,
|
|
@@ -4875,8 +4890,7 @@ function createXNote(host_1) {
|
|
|
4875
4890
|
HighlightBoxComponent,
|
|
4876
4891
|
ListComponent,
|
|
4877
4892
|
VideoComponent
|
|
4878
|
-
],
|
|
4879
|
-
formatters: [
|
|
4893
|
+
], formatters: [
|
|
4880
4894
|
backgroundColorFormatter,
|
|
4881
4895
|
boldFormatter,
|
|
4882
4896
|
codeFormatter,
|
|
@@ -4887,18 +4901,14 @@ function createXNote(host_1) {
|
|
|
4887
4901
|
linkFormatter,
|
|
4888
4902
|
strikeThroughFormatter,
|
|
4889
4903
|
underlineFormatter
|
|
4890
|
-
],
|
|
4891
|
-
attributes: [
|
|
4904
|
+
], attributes: [
|
|
4892
4905
|
headingAttr,
|
|
4893
4906
|
textAlignAttr,
|
|
4894
4907
|
textIndentAttr
|
|
4895
|
-
],
|
|
4896
|
-
providers: [],
|
|
4897
|
-
plugins: [
|
|
4908
|
+
], plugins: [
|
|
4898
4909
|
new LeftToolbarPlugin(),
|
|
4899
4910
|
new ToolbarPlugin(),
|
|
4900
|
-
],
|
|
4901
|
-
onAfterStartup(textbus) {
|
|
4911
|
+
], onAfterStartup(textbus) {
|
|
4902
4912
|
registerBoldShortcut(textbus);
|
|
4903
4913
|
registerCodeShortcut(textbus);
|
|
4904
4914
|
registerItalicShortcut(textbus);
|
|
@@ -4907,32 +4917,34 @@ function createXNote(host_1) {
|
|
|
4907
4917
|
registerHeadingShortcut(textbus);
|
|
4908
4918
|
registerTextAlignShortcut(textbus);
|
|
4909
4919
|
registerTextIndentShortcut(textbus);
|
|
4910
|
-
}
|
|
4911
|
-
|
|
4920
|
+
} }, editorConfig));
|
|
4921
|
+
this.editorConfig = editorConfig;
|
|
4922
|
+
this.translator = new platformBrowser$1.OutputTranslator();
|
|
4923
|
+
this.vDomAdapter = vDomAdapter;
|
|
4924
|
+
}
|
|
4925
|
+
mount(host) {
|
|
4926
|
+
this.host = host;
|
|
4912
4927
|
let rootComp;
|
|
4928
|
+
const config = this.editorConfig;
|
|
4913
4929
|
if (config.content) {
|
|
4914
|
-
const parser =
|
|
4930
|
+
const parser = this.get(platformBrowser.Parser);
|
|
4915
4931
|
const doc = parser.parseDoc(config.content, rootComponentLoader);
|
|
4916
|
-
rootComp = doc instanceof core$1.Component ? doc : new RootComponent(
|
|
4917
|
-
heading: new
|
|
4932
|
+
rootComp = doc instanceof core$1.Component ? doc : new RootComponent(this, {
|
|
4933
|
+
// heading: new Slot([ContentType.Text]),
|
|
4918
4934
|
content: doc
|
|
4919
4935
|
});
|
|
4920
4936
|
}
|
|
4921
4937
|
else {
|
|
4922
|
-
rootComp = new RootComponent(
|
|
4923
|
-
heading: new
|
|
4938
|
+
rootComp = new RootComponent(this, {
|
|
4939
|
+
// heading: new Slot([ContentType.Text]),
|
|
4924
4940
|
content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
|
|
4925
4941
|
});
|
|
4926
4942
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
return translator.transform(vDomAdapter.host);
|
|
4933
|
-
}
|
|
4934
|
-
};
|
|
4935
|
-
});
|
|
4943
|
+
return this.render(rootComp);
|
|
4944
|
+
}
|
|
4945
|
+
getHTML() {
|
|
4946
|
+
return this.translator.transform(this.vDomAdapter.host);
|
|
4947
|
+
}
|
|
4936
4948
|
}
|
|
4937
4949
|
|
|
4938
4950
|
exports.AttrTool = AttrTool;
|
|
@@ -4948,6 +4960,7 @@ exports.Divider = Divider;
|
|
|
4948
4960
|
exports.DragResize = DragResize;
|
|
4949
4961
|
exports.Dropdown = Dropdown;
|
|
4950
4962
|
exports.DropdownMenuPortal = DropdownMenuPortal;
|
|
4963
|
+
exports.Editor = Editor;
|
|
4951
4964
|
exports.FontFamilyTool = FontFamilyTool;
|
|
4952
4965
|
exports.FontSizeTool = FontSizeTool;
|
|
4953
4966
|
exports.HighlightBoxComponent = HighlightBoxComponent;
|
|
@@ -4992,7 +5005,6 @@ exports.codeFormatLoader = codeFormatLoader;
|
|
|
4992
5005
|
exports.codeFormatter = codeFormatter;
|
|
4993
5006
|
exports.colorFormatLoader = colorFormatLoader;
|
|
4994
5007
|
exports.colorFormatter = colorFormatter;
|
|
4995
|
-
exports.createXNote = createXNote;
|
|
4996
5008
|
exports.deltaToBlock = deltaToBlock;
|
|
4997
5009
|
exports.fontFamilyFormatLoader = fontFamilyFormatLoader;
|
|
4998
5010
|
exports.fontFamilyFormatter = fontFamilyFormatter;
|