@textbus/xnote 0.0.11 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/components/_api.d.ts +1 -0
- package/bundles/components/color-picker/color-picker.d.ts +28 -0
- package/bundles/index.css +1 -1
- package/bundles/index.esm.css +1 -1
- package/bundles/index.esm.js +571 -181
- package/bundles/index.js +572 -178
- package/bundles/textbus/attributes/_api.d.ts +1 -0
- package/bundles/textbus/attributes/cell-background.attr.d.ts +4 -0
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from '@viewfly/core/jsx-runtime';
|
|
2
2
|
import { withScopedCSS } from '@viewfly/scoped-css';
|
|
3
|
-
import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onUpdated, onMounted, InjectionToken,
|
|
4
|
-
import { Subject,
|
|
3
|
+
import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, getCurrentInstance, createRef, withAnnotation, onUpdated, onMounted, InjectionToken, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, Fragment as Fragment$1, watch } from '@viewfly/core';
|
|
4
|
+
import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, throttleTime, delay, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
|
|
5
|
+
import { normalizeHex, hex2Hsl, hex2Rgb, hex2Hsv, hsl2Hex, hsl2Hsv, hsl2Rgb, rgb2Hsl, rgb2Hex, rgb2Hsv, hsv2Hex, hsv2Hsl, hsv2Rgb, any2Hsl, parseCss } from '@tanbo/color';
|
|
5
6
|
import { VIEW_CONTAINER, isMac, DomAdapter, Input, SelectionBridge, BrowserModule, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, CollaborateCursor, Parser } from '@textbus/platform-browser';
|
|
6
7
|
import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
|
|
7
8
|
import { useProduce } from '@viewfly/hooks';
|
|
@@ -9,10 +10,9 @@ import highlightjs from 'highlight.js';
|
|
|
9
10
|
import { v4 } from 'uuid';
|
|
10
11
|
import Katex from 'katex';
|
|
11
12
|
import { ViewflyAdapter, ViewflyVDomAdapter } from '@textbus/adapter-viewfly';
|
|
12
|
-
import { any2Hsl, hsl2Rgb } from '@tanbo/color';
|
|
13
13
|
import { MessageBus, CollaborateModule } from '@textbus/collaborate';
|
|
14
14
|
|
|
15
|
-
var scopedId$
|
|
15
|
+
var scopedId$o = "vf-d94b56";
|
|
16
16
|
|
|
17
17
|
/******************************************************************************
|
|
18
18
|
Copyright (c) Microsoft Corporation.
|
|
@@ -145,7 +145,7 @@ function Button(props) {
|
|
|
145
145
|
subscription.unsubscribe();
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
return withScopedCSS(scopedId$
|
|
148
|
+
return withScopedCSS(scopedId$o, () => {
|
|
149
149
|
return (jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
150
150
|
'btn',
|
|
151
151
|
{
|
|
@@ -157,6 +157,346 @@ function Button(props) {
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
var scopedId$n = "vf-d552b9";
|
|
161
|
+
|
|
162
|
+
class Picker {
|
|
163
|
+
set hex(color) {
|
|
164
|
+
var _a;
|
|
165
|
+
const c = color ? normalizeHex(color) : null;
|
|
166
|
+
if (c) {
|
|
167
|
+
this.empty = false;
|
|
168
|
+
this._hex = c;
|
|
169
|
+
this._hsl = hex2Hsl(c);
|
|
170
|
+
this._rgb = hex2Rgb(c);
|
|
171
|
+
this._hsv = hex2Hsv(c);
|
|
172
|
+
this._rgba = Object.assign(Object.assign({}, this._rgb), { a: this.resetAlpha ? 1 : ((_a = this._rgba) === null || _a === void 0 ? void 0 : _a.a) || 1 });
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.empty = true;
|
|
176
|
+
}
|
|
177
|
+
this.resetAlpha = true;
|
|
178
|
+
this.onChange();
|
|
179
|
+
}
|
|
180
|
+
get hex() {
|
|
181
|
+
return this.empty ? null : this._hex;
|
|
182
|
+
}
|
|
183
|
+
set hsl(color) {
|
|
184
|
+
var _a;
|
|
185
|
+
if (!color || typeof color.h !== 'number' || typeof color.s !== 'number' || typeof color.l !== 'number') {
|
|
186
|
+
this.empty = true;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.empty = false;
|
|
190
|
+
this._hsl = color;
|
|
191
|
+
this._hex = hsl2Hex(color);
|
|
192
|
+
this._hsv = hsl2Hsv(color);
|
|
193
|
+
this._rgb = hsl2Rgb(color);
|
|
194
|
+
this._rgba = Object.assign(Object.assign({}, this._rgb), { a: this.resetAlpha ? 1 : ((_a = this._rgba) === null || _a === void 0 ? void 0 : _a.a) || 1 });
|
|
195
|
+
}
|
|
196
|
+
this.resetAlpha = true;
|
|
197
|
+
this.onChange();
|
|
198
|
+
}
|
|
199
|
+
get hsl() {
|
|
200
|
+
return this.empty ? null : this._hsl;
|
|
201
|
+
}
|
|
202
|
+
set rgb(color) {
|
|
203
|
+
var _a;
|
|
204
|
+
if (!color || typeof color.r !== 'number' || typeof color.g !== 'number' || typeof color.b !== 'number') {
|
|
205
|
+
this.empty = true;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
this.empty = false;
|
|
209
|
+
this._rgb = color;
|
|
210
|
+
this._rgba = Object.assign(Object.assign({}, color), { a: this.resetAlpha ? 1 : ((_a = this._rgba) === null || _a === void 0 ? void 0 : _a.a) || 1 });
|
|
211
|
+
this._hsl = rgb2Hsl(color);
|
|
212
|
+
this._hex = rgb2Hex(color);
|
|
213
|
+
this._hsv = rgb2Hsv(color);
|
|
214
|
+
}
|
|
215
|
+
this.resetAlpha = true;
|
|
216
|
+
this.onChange();
|
|
217
|
+
}
|
|
218
|
+
get rgb() {
|
|
219
|
+
return this.empty ? null : this._rgb;
|
|
220
|
+
}
|
|
221
|
+
set rgba(color) {
|
|
222
|
+
if (!color ||
|
|
223
|
+
typeof color.r !== 'number' ||
|
|
224
|
+
typeof color.g !== 'number' ||
|
|
225
|
+
typeof color.b !== 'number' ||
|
|
226
|
+
typeof color.a !== 'number') {
|
|
227
|
+
this.empty = true;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.empty = false;
|
|
231
|
+
this._rgba = color;
|
|
232
|
+
this._hsl = rgb2Hsl(color);
|
|
233
|
+
this._hex = rgb2Hex(color);
|
|
234
|
+
this._hsv = rgb2Hsv(color);
|
|
235
|
+
}
|
|
236
|
+
this.onChange();
|
|
237
|
+
}
|
|
238
|
+
get rgba() {
|
|
239
|
+
return this.empty ? null : this._rgba;
|
|
240
|
+
}
|
|
241
|
+
set hsv(color) {
|
|
242
|
+
var _a;
|
|
243
|
+
if (!color || typeof color.h !== 'number' || typeof color.s !== 'number' || typeof color.v !== 'number') {
|
|
244
|
+
this.empty = true;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.empty = false;
|
|
248
|
+
this._hsv = color;
|
|
249
|
+
this._hex = hsv2Hex(color);
|
|
250
|
+
this._hsl = hsv2Hsl(color);
|
|
251
|
+
this._rgb = hsv2Rgb(color);
|
|
252
|
+
this._rgba = Object.assign(Object.assign({}, this._rgb), { a: this.resetAlpha ? 1 : ((_a = this._rgba) === null || _a === void 0 ? void 0 : _a.a) || 1 });
|
|
253
|
+
}
|
|
254
|
+
this.resetAlpha = true;
|
|
255
|
+
this.onChange();
|
|
256
|
+
}
|
|
257
|
+
get hsv() {
|
|
258
|
+
return this.empty ? null : this._hsv;
|
|
259
|
+
}
|
|
260
|
+
constructor(onChange, value) {
|
|
261
|
+
this.onChange = onChange;
|
|
262
|
+
this._hex = '';
|
|
263
|
+
this._hsl = null;
|
|
264
|
+
this._rgb = null;
|
|
265
|
+
this._hsv = null;
|
|
266
|
+
this._rgba = null;
|
|
267
|
+
this.empty = false;
|
|
268
|
+
this.resetAlpha = true;
|
|
269
|
+
this.hex = value || '#f00';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const recentColors = createSignal([]);
|
|
273
|
+
function ColorPicker(props) {
|
|
274
|
+
const instance = getCurrentInstance();
|
|
275
|
+
const picker = new Picker(() => {
|
|
276
|
+
instance.markAsDirtied();
|
|
277
|
+
}, props.value);
|
|
278
|
+
const mainColors = [
|
|
279
|
+
'#000', '#333', '#444', '#555', '#666', '#777', '#888',
|
|
280
|
+
'#999', '#aaa', '#bbb', '#ccc', '#ddd', '#eee', '#fff',
|
|
281
|
+
];
|
|
282
|
+
const colors = [
|
|
283
|
+
'#fec6c2', '#fee5c3', '#fefcc3', '#baf6c4', '#c3ebfe', '#c3cbfe', '#e1caff',
|
|
284
|
+
'#fc8e88', '#fccc88', '#fcf888', '#76ec8a', '#88d8fc', '#97a4fb', '#c098f4',
|
|
285
|
+
'#ff6666', '#ffb151', '#fada3a', '#18c937', '#3aaafa', '#6373e2', '#a669f7',
|
|
286
|
+
'#f63030', '#f88933', '#deb12a', '#038e23', '#1276cc', '#3f52ce', '#8838ed',
|
|
287
|
+
'#c60000', '#d86912', '#b88811', '#086508', '#144c93', '#1b2eaa', '#6117bf',
|
|
288
|
+
];
|
|
289
|
+
function addRecentColor() {
|
|
290
|
+
const color = picker.hex;
|
|
291
|
+
if (!color) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const colors = recentColors().filter(item => {
|
|
295
|
+
return item !== color;
|
|
296
|
+
});
|
|
297
|
+
colors.unshift(color);
|
|
298
|
+
if (colors.length >= 7) {
|
|
299
|
+
colors.length = 7;
|
|
300
|
+
}
|
|
301
|
+
recentColors.set(colors);
|
|
302
|
+
}
|
|
303
|
+
const paletteRef = createRef();
|
|
304
|
+
function bindPaletteEvent(ev) {
|
|
305
|
+
const update = (ev) => {
|
|
306
|
+
var _a;
|
|
307
|
+
const position = paletteRef.current.getBoundingClientRect();
|
|
308
|
+
const offsetX = ev.clientX - position.left;
|
|
309
|
+
const offsetY = ev.clientY - position.top;
|
|
310
|
+
let s = offsetX / 130 * 100;
|
|
311
|
+
let v = 100 - offsetY / 130 * 100;
|
|
312
|
+
s = Math.max(0, s);
|
|
313
|
+
s = Math.min(100, s);
|
|
314
|
+
v = Math.max(0, v);
|
|
315
|
+
v = Math.min(100, v);
|
|
316
|
+
picker.resetAlpha = false;
|
|
317
|
+
picker.hsv = {
|
|
318
|
+
h: picker.hsv.h,
|
|
319
|
+
s,
|
|
320
|
+
v
|
|
321
|
+
};
|
|
322
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
323
|
+
};
|
|
324
|
+
update(ev);
|
|
325
|
+
const unMouseMove = fromEvent(document, 'mousemove').subscribe(ev => {
|
|
326
|
+
update(ev);
|
|
327
|
+
});
|
|
328
|
+
const unMouseUp = fromEvent(document, 'mouseup').subscribe(() => {
|
|
329
|
+
unMouseMove.unsubscribe();
|
|
330
|
+
unMouseUp.unsubscribe();
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const hueBarRef = createRef();
|
|
334
|
+
function bindHueBarEvent(ev) {
|
|
335
|
+
const update = (ev) => {
|
|
336
|
+
var _a;
|
|
337
|
+
const position = hueBarRef.current.getBoundingClientRect();
|
|
338
|
+
let offsetY = ev.clientY - position.top;
|
|
339
|
+
offsetY = Math.max(0, offsetY);
|
|
340
|
+
offsetY = Math.min(100, offsetY);
|
|
341
|
+
const h = 360 / 100 * offsetY;
|
|
342
|
+
picker.resetAlpha = false;
|
|
343
|
+
picker.hsv = {
|
|
344
|
+
h,
|
|
345
|
+
s: picker.hsv.s,
|
|
346
|
+
v: picker.hsv.v
|
|
347
|
+
};
|
|
348
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
349
|
+
};
|
|
350
|
+
update(ev);
|
|
351
|
+
const unMouseMove = fromEvent(document, 'mousemove').subscribe(ev => {
|
|
352
|
+
update(ev);
|
|
353
|
+
});
|
|
354
|
+
const unMouseUp = fromEvent(document, 'mouseup').subscribe(() => {
|
|
355
|
+
unMouseMove.unsubscribe();
|
|
356
|
+
unMouseUp.unsubscribe();
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
const alphaBarRef = createRef();
|
|
360
|
+
function bindAlphaEvent(ev) {
|
|
361
|
+
const update = (ev) => {
|
|
362
|
+
var _a;
|
|
363
|
+
const position = alphaBarRef.current.getBoundingClientRect();
|
|
364
|
+
let offsetX = ev.clientX - position.left;
|
|
365
|
+
offsetX = Math.max(0, offsetX);
|
|
366
|
+
offsetX = Math.min(position.width, offsetX);
|
|
367
|
+
picker.rgba = Object.assign(Object.assign({}, picker.rgba), { a: offsetX / position.width });
|
|
368
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
369
|
+
};
|
|
370
|
+
update(ev);
|
|
371
|
+
const unMouseMove = fromEvent(document, 'mousemove').subscribe(ev => {
|
|
372
|
+
update(ev);
|
|
373
|
+
});
|
|
374
|
+
const unMouseUp = fromEvent(document, 'mouseup').subscribe(() => {
|
|
375
|
+
unMouseMove.unsubscribe();
|
|
376
|
+
unMouseUp.unsubscribe();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function bindInputsEvent(ev) {
|
|
380
|
+
var _a;
|
|
381
|
+
const updateByHSL = (h, s, l) => {
|
|
382
|
+
var _a;
|
|
383
|
+
picker.hex = hsl2Hex({ h, s, l });
|
|
384
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
385
|
+
};
|
|
386
|
+
const updateByRGB = (r, g, b) => {
|
|
387
|
+
var _a;
|
|
388
|
+
picker.hex = rgb2Hex({ r, g, b });
|
|
389
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
390
|
+
};
|
|
391
|
+
const el = ev.target;
|
|
392
|
+
const model = el.getAttribute('data-model');
|
|
393
|
+
if (el.type === 'number') {
|
|
394
|
+
const min = +el.min;
|
|
395
|
+
const max = +el.max;
|
|
396
|
+
el.value = Math.max(+el.value, min) + '';
|
|
397
|
+
el.value = Math.min(+el.value, max) + '';
|
|
398
|
+
}
|
|
399
|
+
const { h, s, l } = picker.hsl;
|
|
400
|
+
const { r, g, b } = picker.rgb;
|
|
401
|
+
switch (model) {
|
|
402
|
+
case 'H':
|
|
403
|
+
updateByHSL(+el.value, s, l);
|
|
404
|
+
break;
|
|
405
|
+
case 'S':
|
|
406
|
+
updateByHSL(h, +el.value, l);
|
|
407
|
+
break;
|
|
408
|
+
case 'L':
|
|
409
|
+
updateByHSL(h, s, +el.value);
|
|
410
|
+
break;
|
|
411
|
+
case 'R':
|
|
412
|
+
updateByRGB(+el.value, g, b);
|
|
413
|
+
break;
|
|
414
|
+
case 'G':
|
|
415
|
+
updateByRGB(r, +el.value, b);
|
|
416
|
+
break;
|
|
417
|
+
case 'B':
|
|
418
|
+
updateByRGB(r, g, +el.value);
|
|
419
|
+
break;
|
|
420
|
+
case 'HEX':
|
|
421
|
+
if (/^#(([0-9a-f]){3}){1,2}$/i.test(el.value)) {
|
|
422
|
+
picker.hex = el.value;
|
|
423
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, picker);
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const isShowPalette = createSignal(false);
|
|
429
|
+
function selected() {
|
|
430
|
+
props.onSelected(picker);
|
|
431
|
+
addRecentColor();
|
|
432
|
+
isShowPalette.set(false);
|
|
433
|
+
}
|
|
434
|
+
function bindColorOptionsEvent(ev) {
|
|
435
|
+
const target = ev.target;
|
|
436
|
+
if (!target.hasAttribute('data-color')) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const c = target.getAttribute('data-color');
|
|
440
|
+
if (/^rgba/.test(c)) {
|
|
441
|
+
picker.rgba = parseCss(c);
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
picker.hex = c;
|
|
445
|
+
}
|
|
446
|
+
props.onSelected(picker);
|
|
447
|
+
addRecentColor();
|
|
448
|
+
}
|
|
449
|
+
return withScopedCSS(scopedId$n, () => {
|
|
450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
451
|
+
return (jsxs("div", { onMousedown: ev => {
|
|
452
|
+
ev.stopPropagation();
|
|
453
|
+
}, class: {
|
|
454
|
+
'xnote-color-picker': true,
|
|
455
|
+
'xnote-color-picker-show-palette': isShowPalette()
|
|
456
|
+
}, children: [jsxs("div", { class: "xnote-color-picker-preset", onClick: bindColorOptionsEvent, children: [jsx("div", { class: "xnote-color-picker-swatches", style: "height: 50px", children: mainColors.map(color => {
|
|
457
|
+
var _a, _b, _c;
|
|
458
|
+
const hsl = (any2Hsl(color) || {});
|
|
459
|
+
return (jsx("div", { "data-color": color, class: {
|
|
460
|
+
'xnote-color-picker-current': hsl.l === ((_a = picker.hsl) === null || _a === void 0 ? void 0 : _a.l) && hsl.s === ((_b = picker.hsl) === null || _b === void 0 ? void 0 : _b.s) && hsl.h === ((_c = picker.hsl) === null || _c === void 0 ? void 0 : _c.h),
|
|
461
|
+
}, style: {
|
|
462
|
+
background: color
|
|
463
|
+
} }));
|
|
464
|
+
}) }), jsx("div", { class: "xnote-color-picker-swatches", style: "height: 118px;", children: colors.map(color => {
|
|
465
|
+
return (jsx("div", { "data-color": color, style: {
|
|
466
|
+
background: color
|
|
467
|
+
} }));
|
|
468
|
+
}) }), jsx("div", { class: "xnote-color-picker-recent-text", children: "\u6700\u8FD1\u989C\u8272" }), jsx("div", { class: "xnote-color-picker-swatches", style: "height: 25px;", children: Array.from({ length: 7 }).map((_, index) => {
|
|
469
|
+
const colors = recentColors();
|
|
470
|
+
const color = colors[index] || '';
|
|
471
|
+
return (jsx("div", { "data-color": color || 'unknown', style: {
|
|
472
|
+
background: color
|
|
473
|
+
} }));
|
|
474
|
+
}) }), jsxs("div", { class: "xnote-color-picker-flex", children: [jsx("div", { class: "xnote-color-picker-swatches", children: jsx("div", { "data-color": "" }) }), jsxs("button", { type: "button", class: "xnote-color-picker-to-palette", onClick: () => {
|
|
475
|
+
isShowPalette.set(true);
|
|
476
|
+
}, children: ["\u8C03\u8272\u76D8", jsx("svg", { style: "vertical-align: middle;fill: currentColor;overflow: hidden;", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { transform: "rotate(180, 512, 512)", d: "M497.92 165.12L422.4 89.6 0 512l422.4 422.4 75.52-75.52L151.04 512z" }) })] })] })] }), jsxs("div", { class: "xnote-color-picker-menu", children: [jsx("div", { class: "xnote-color-picker-back-btn-wrap", children: jsxs("button", { type: "button", class: "xnote-color-picker-back-btn", onClick: () => {
|
|
477
|
+
isShowPalette.set(false);
|
|
478
|
+
}, children: [jsx("svg", { style: "vertical-align: middle;fill: currentColor;overflow: hidden;", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M497.92 165.12L422.4 89.6 0 512l422.4 422.4 75.52-75.52L151.04 512z" }) }), "\u8FD4\u56DE"] }) }), jsxs("div", { class: "xnote-color-picker-viewer", children: [jsxs("div", { class: "xnote-color-picker-viewer-left", children: [jsx("div", { class: [
|
|
479
|
+
'xnote-color-picker-palette',
|
|
480
|
+
{
|
|
481
|
+
'xnote-color-picker-palette-empty': picker.empty
|
|
482
|
+
}
|
|
483
|
+
], style: {
|
|
484
|
+
background: picker.empty ? '' : `linear-gradient(to right, #fff, hsl(${(_a = picker.hsv) === null || _a === void 0 ? void 0 : _a.h}, 100%, 50%))`
|
|
485
|
+
}, ref: paletteRef, onMousedown: bindPaletteEvent, children: jsx("div", { class: "xnote-color-picker-palette-point", style: {
|
|
486
|
+
left: `calc(${(_b = picker.hsv) === null || _b === void 0 ? void 0 : _b.s}% - 6px)`,
|
|
487
|
+
top: `calc(${100 - (((_c = picker.hsv) === null || _c === void 0 ? void 0 : _c.v) || 0)}% - 6px)`
|
|
488
|
+
} }) }), jsxs("div", { class: "xnote-color-picker-viewer-alpha", children: [jsx("div", { class: "xnote-color-picker-viewer-alpha-pointer", style: {
|
|
489
|
+
left: picker.empty ? '100%' : (((_d = picker.rgba) === null || _d === void 0 ? void 0 : _d.a) || 0) * 100 + '%',
|
|
490
|
+
} }), jsx("div", { class: "xnote-color-picker-viewer-alpha-bar", style: {
|
|
491
|
+
background: picker.empty ? '' : `linear-gradient(to right, transparent, ${picker.hex})`
|
|
492
|
+
}, onMousedown: bindAlphaEvent, ref: alphaBarRef })] })] }), jsxs("div", { class: "xnote-color-picker-viewer-right", children: [jsxs("div", { class: "xnote-color-picker-tools", children: [jsx("div", { class: "xnote-color-picker-value", children: jsx("div", { class: "xnote-color-picker-value-color", style: {
|
|
493
|
+
background: picker.empty ? '' : `rgba(${(_e = picker.rgba) === null || _e === void 0 ? void 0 : _e.r}, ${(_f = picker.rgba) === null || _f === void 0 ? void 0 : _f.g}, ${(_g = picker.rgba) === null || _g === void 0 ? void 0 : _g.b}, ${(_h = picker.rgba) === null || _h === void 0 ? void 0 : _h.a})`
|
|
494
|
+
} }) }), jsx("div", { class: "xnote-color-picker-hue-bar", ref: hueBarRef, onMousedown: bindHueBarEvent, children: jsx("div", { class: "xnote-color-picker-hue-pointer", style: {
|
|
495
|
+
top: `calc(${(((_j = picker.hsv) === null || _j === void 0 ? void 0 : _j.h) || 0) / 360 * 100}% - 4px)`
|
|
496
|
+
} }) })] }), jsx("div", { class: "xnote-color-picker-viewer-alpha-value", children: Number((_k = picker.rgba) === null || _k === void 0 ? void 0 : _k.a.toFixed(2)) })] })] }), jsxs("div", { class: "xnote-color-picker-inputs", onInput: bindInputsEvent, children: [jsxs("div", { class: "xnote-color-picker-hsl", children: [jsxs("div", { children: ["H ", jsx("input", { "data-model": "H", min: "0", max: "360", type: "number", value: (_l = picker.hsl) === null || _l === void 0 ? void 0 : _l.h })] }), jsxs("div", { children: ["S ", jsx("input", { "data-model": "S", min: "0", max: "100", type: "number", value: (_m = picker.hsl) === null || _m === void 0 ? void 0 : _m.s })] }), jsxs("div", { children: ["L ", jsx("input", { "data-model": "L", min: "0", max: "100", type: "number", value: (_o = picker.hsl) === null || _o === void 0 ? void 0 : _o.l })] })] }), jsxs("div", { class: "xnote-color-picker-rgb", children: [jsxs("div", { children: ["R ", jsx("input", { "data-model": "R", min: "0", max: "255", type: "number", value: (_p = picker.rgb) === null || _p === void 0 ? void 0 : _p.r })] }), jsxs("div", { children: ["G ", jsx("input", { "data-model": "G", min: "0", max: "255", type: "number", value: (_q = picker.rgb) === null || _q === void 0 ? void 0 : _q.g })] }), jsxs("div", { children: ["B ", jsx("input", { "data-model": "B", min: "0", max: "255", type: "number", value: (_r = picker.rgb) === null || _r === void 0 ? void 0 : _r.b })] })] }), jsx("div", { class: "xnote-color-picker-hex", children: jsxs("div", { children: ["HEX ", jsx("input", { "data-model": "HEX", type: "text", value: picker.hex })] }) })] }), jsx("div", { class: "xnote-color-picker-btn-wrap", children: jsx("button", { type: "button", class: "xnote-color-picker-btn", onClick: selected, children: "\u786E\u5B9A" }) })] })] }));
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
160
500
|
var scopedId$m = "vf-ac7e8d";
|
|
161
501
|
|
|
162
502
|
function ComponentToolbar(props) {
|
|
@@ -937,6 +1277,166 @@ const highlightBoxComponentLoader = {
|
|
|
937
1277
|
}
|
|
938
1278
|
};
|
|
939
1279
|
|
|
1280
|
+
const fontSizeFormatter = new Formatter('fontSize', {
|
|
1281
|
+
render(children, formatValue) {
|
|
1282
|
+
return {
|
|
1283
|
+
fallbackTagName: 'span',
|
|
1284
|
+
attach(host) {
|
|
1285
|
+
host.styles.set('fontSize', formatValue);
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
const fontSizeFormatLoader = {
|
|
1291
|
+
match(element) {
|
|
1292
|
+
return !!element.style.fontSize;
|
|
1293
|
+
},
|
|
1294
|
+
read(element) {
|
|
1295
|
+
return {
|
|
1296
|
+
formatter: fontSizeFormatter,
|
|
1297
|
+
value: element.style.fontSize
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
const boldFormatter = new Formatter('bold', {
|
|
1303
|
+
render(children) {
|
|
1304
|
+
return createVNode('strong', null, children);
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
function toggleBold(textbus) {
|
|
1308
|
+
const controller = textbus.get(Controller);
|
|
1309
|
+
if (controller.readonly) {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
const query = textbus.get(Query);
|
|
1313
|
+
const commander = textbus.get(Commander);
|
|
1314
|
+
const state = query.queryFormat(boldFormatter);
|
|
1315
|
+
if (state.state === QueryStateType.Normal) {
|
|
1316
|
+
commander.applyFormat(boldFormatter, true);
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
commander.unApplyFormat(boldFormatter);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
function registerBoldShortcut(textbus) {
|
|
1323
|
+
const keyboard = textbus.get(Keyboard);
|
|
1324
|
+
keyboard.addShortcut({
|
|
1325
|
+
keymap: {
|
|
1326
|
+
modKey: true,
|
|
1327
|
+
key: 'b'
|
|
1328
|
+
},
|
|
1329
|
+
action: () => {
|
|
1330
|
+
toggleBold(textbus);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
const boldFormatLoader = {
|
|
1335
|
+
match(element) {
|
|
1336
|
+
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
1337
|
+
},
|
|
1338
|
+
read() {
|
|
1339
|
+
return {
|
|
1340
|
+
formatter: boldFormatter,
|
|
1341
|
+
value: true
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
const colorFormatter = new Formatter('color', {
|
|
1347
|
+
render(children, formatValue) {
|
|
1348
|
+
return {
|
|
1349
|
+
fallbackTagName: 'span',
|
|
1350
|
+
attach(host) {
|
|
1351
|
+
host.styles.set('color', formatValue);
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
const colorFormatLoader = {
|
|
1357
|
+
match(element) {
|
|
1358
|
+
return !!element.style.color;
|
|
1359
|
+
},
|
|
1360
|
+
read(element) {
|
|
1361
|
+
return {
|
|
1362
|
+
formatter: colorFormatter,
|
|
1363
|
+
value: element.style.color
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
function createTimelineItem(textbus, theme) {
|
|
1369
|
+
const slot = new Slot([
|
|
1370
|
+
ContentType.BlockComponent,
|
|
1371
|
+
]);
|
|
1372
|
+
const title = new ParagraphComponent(textbus);
|
|
1373
|
+
title.state.slot.insert('时间主题', [
|
|
1374
|
+
[fontSizeFormatter, '18px'],
|
|
1375
|
+
[boldFormatter, true]
|
|
1376
|
+
]);
|
|
1377
|
+
title.state.slot.insert(' 2020-02-02', [
|
|
1378
|
+
[fontSizeFormatter, '15px'],
|
|
1379
|
+
[colorFormatter, '#777']
|
|
1380
|
+
]);
|
|
1381
|
+
const desc = new ParagraphComponent(textbus);
|
|
1382
|
+
desc.state.slot.insert('描述信息...');
|
|
1383
|
+
slot.insert(title);
|
|
1384
|
+
slot.insert(desc);
|
|
1385
|
+
return { theme, slot };
|
|
1386
|
+
}
|
|
1387
|
+
class TimelineComponent extends Component {
|
|
1388
|
+
static fromJSON(textbus, json) {
|
|
1389
|
+
const registry = textbus.get(Registry);
|
|
1390
|
+
return new TimelineComponent(textbus, {
|
|
1391
|
+
items: json.items.map(i => {
|
|
1392
|
+
return {
|
|
1393
|
+
theme: i.theme,
|
|
1394
|
+
slot: registry.createSlot(i.slot)
|
|
1395
|
+
};
|
|
1396
|
+
})
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
getSlots() {
|
|
1400
|
+
return this.state.items.map(i => i.slot);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
TimelineComponent.componentName = 'TimelineComponent';
|
|
1404
|
+
TimelineComponent.type = ContentType.BlockComponent;
|
|
1405
|
+
|
|
1406
|
+
function createStepItem(textbus) {
|
|
1407
|
+
const slot = new Slot([
|
|
1408
|
+
ContentType.BlockComponent
|
|
1409
|
+
]);
|
|
1410
|
+
const title = new ParagraphComponent(textbus);
|
|
1411
|
+
title.state.slot.insert('标题', [
|
|
1412
|
+
[fontSizeFormatter, '18px'],
|
|
1413
|
+
[boldFormatter, true]
|
|
1414
|
+
]);
|
|
1415
|
+
const content = new ParagraphComponent(textbus);
|
|
1416
|
+
content.state.slot.insert('描述信息...');
|
|
1417
|
+
slot.insert(title);
|
|
1418
|
+
slot.insert(content);
|
|
1419
|
+
return { slot };
|
|
1420
|
+
}
|
|
1421
|
+
class StepComponent extends Component {
|
|
1422
|
+
static fromJSON(textbus, json) {
|
|
1423
|
+
const registry = textbus.get(Registry);
|
|
1424
|
+
return new StepComponent(textbus, {
|
|
1425
|
+
step: json.step,
|
|
1426
|
+
items: json.items.map(i => {
|
|
1427
|
+
return {
|
|
1428
|
+
slot: registry.createSlot(i.slot)
|
|
1429
|
+
};
|
|
1430
|
+
})
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
getSlots() {
|
|
1434
|
+
return this.state.items.map(i => i.slot);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
StepComponent.componentName = 'StepComponent';
|
|
1438
|
+
StepComponent.type = ContentType.BlockComponent;
|
|
1439
|
+
|
|
940
1440
|
class ParagraphComponent extends Component {
|
|
941
1441
|
static fromJSON(textbus, json) {
|
|
942
1442
|
const slot = textbus.get(Registry).createSlot(json.slot);
|
|
@@ -967,7 +1467,9 @@ class ParagraphComponent extends Component {
|
|
|
967
1467
|
slot: afterSlot
|
|
968
1468
|
});
|
|
969
1469
|
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
970
|
-
this.parentComponent instanceof HighlightBoxComponent
|
|
1470
|
+
this.parentComponent instanceof HighlightBoxComponent ||
|
|
1471
|
+
this.parentComponent instanceof TimelineComponent ||
|
|
1472
|
+
this.parentComponent instanceof StepComponent)) {
|
|
971
1473
|
commander.insertAfter(nextParagraph, this.parentComponent);
|
|
972
1474
|
commander.removeComponent(this);
|
|
973
1475
|
}
|
|
@@ -3153,7 +3655,7 @@ const backgroundColorFormatter = new Formatter('backgroundColor', {
|
|
|
3153
3655
|
});
|
|
3154
3656
|
const backgroundColorFormatLoader = {
|
|
3155
3657
|
match(element) {
|
|
3156
|
-
return !!element.style.backgroundColor;
|
|
3658
|
+
return element.tagName !== 'TD' && element.tagName !== 'TH' && !!element.style.backgroundColor;
|
|
3157
3659
|
},
|
|
3158
3660
|
read(element) {
|
|
3159
3661
|
return {
|
|
@@ -3163,50 +3665,6 @@ const backgroundColorFormatLoader = {
|
|
|
3163
3665
|
}
|
|
3164
3666
|
};
|
|
3165
3667
|
|
|
3166
|
-
const boldFormatter = new Formatter('bold', {
|
|
3167
|
-
render(children) {
|
|
3168
|
-
return createVNode('strong', null, children);
|
|
3169
|
-
}
|
|
3170
|
-
});
|
|
3171
|
-
function toggleBold(textbus) {
|
|
3172
|
-
const controller = textbus.get(Controller);
|
|
3173
|
-
if (controller.readonly) {
|
|
3174
|
-
return;
|
|
3175
|
-
}
|
|
3176
|
-
const query = textbus.get(Query);
|
|
3177
|
-
const commander = textbus.get(Commander);
|
|
3178
|
-
const state = query.queryFormat(boldFormatter);
|
|
3179
|
-
if (state.state === QueryStateType.Normal) {
|
|
3180
|
-
commander.applyFormat(boldFormatter, true);
|
|
3181
|
-
}
|
|
3182
|
-
else {
|
|
3183
|
-
commander.unApplyFormat(boldFormatter);
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
function registerBoldShortcut(textbus) {
|
|
3187
|
-
const keyboard = textbus.get(Keyboard);
|
|
3188
|
-
keyboard.addShortcut({
|
|
3189
|
-
keymap: {
|
|
3190
|
-
modKey: true,
|
|
3191
|
-
key: 'b'
|
|
3192
|
-
},
|
|
3193
|
-
action: () => {
|
|
3194
|
-
toggleBold(textbus);
|
|
3195
|
-
}
|
|
3196
|
-
});
|
|
3197
|
-
}
|
|
3198
|
-
const boldFormatLoader = {
|
|
3199
|
-
match(element) {
|
|
3200
|
-
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
3201
|
-
},
|
|
3202
|
-
read() {
|
|
3203
|
-
return {
|
|
3204
|
-
formatter: boldFormatter,
|
|
3205
|
-
value: true
|
|
3206
|
-
};
|
|
3207
|
-
}
|
|
3208
|
-
};
|
|
3209
|
-
|
|
3210
3668
|
const codeFormatter = new Formatter('code', {
|
|
3211
3669
|
inheritable: false,
|
|
3212
3670
|
render(children) {
|
|
@@ -3254,28 +3712,6 @@ const codeFormatLoader = {
|
|
|
3254
3712
|
}
|
|
3255
3713
|
};
|
|
3256
3714
|
|
|
3257
|
-
const colorFormatter = new Formatter('color', {
|
|
3258
|
-
render(children, formatValue) {
|
|
3259
|
-
return {
|
|
3260
|
-
fallbackTagName: 'span',
|
|
3261
|
-
attach(host) {
|
|
3262
|
-
host.styles.set('color', formatValue);
|
|
3263
|
-
}
|
|
3264
|
-
};
|
|
3265
|
-
}
|
|
3266
|
-
});
|
|
3267
|
-
const colorFormatLoader = {
|
|
3268
|
-
match(element) {
|
|
3269
|
-
return !!element.style.color;
|
|
3270
|
-
},
|
|
3271
|
-
read(element) {
|
|
3272
|
-
return {
|
|
3273
|
-
formatter: colorFormatter,
|
|
3274
|
-
value: element.style.color
|
|
3275
|
-
};
|
|
3276
|
-
}
|
|
3277
|
-
};
|
|
3278
|
-
|
|
3279
3715
|
const fontFamilyFormatter = new Formatter('fontFamily', {
|
|
3280
3716
|
render(children, formatValue) {
|
|
3281
3717
|
return {
|
|
@@ -3298,28 +3734,6 @@ const fontFamilyFormatLoader = {
|
|
|
3298
3734
|
}
|
|
3299
3735
|
};
|
|
3300
3736
|
|
|
3301
|
-
const fontSizeFormatter = new Formatter('fontSize', {
|
|
3302
|
-
render(children, formatValue) {
|
|
3303
|
-
return {
|
|
3304
|
-
fallbackTagName: 'span',
|
|
3305
|
-
attach(host) {
|
|
3306
|
-
host.styles.set('fontSize', formatValue);
|
|
3307
|
-
}
|
|
3308
|
-
};
|
|
3309
|
-
}
|
|
3310
|
-
});
|
|
3311
|
-
const fontSizeFormatLoader = {
|
|
3312
|
-
match(element) {
|
|
3313
|
-
return !!element.style.fontSize;
|
|
3314
|
-
},
|
|
3315
|
-
read(element) {
|
|
3316
|
-
return {
|
|
3317
|
-
formatter: fontSizeFormatter,
|
|
3318
|
-
value: element.style.fontSize
|
|
3319
|
-
};
|
|
3320
|
-
}
|
|
3321
|
-
};
|
|
3322
|
-
|
|
3323
3737
|
const italicFormatter = new Formatter('italic', {
|
|
3324
3738
|
render(children) {
|
|
3325
3739
|
return createVNode('em', null, children);
|
|
@@ -3966,6 +4380,36 @@ function CellAlignTool() {
|
|
|
3966
4380
|
};
|
|
3967
4381
|
}
|
|
3968
4382
|
|
|
4383
|
+
const cellBackgroundAttr = new Attribute('cellBackground', {
|
|
4384
|
+
render(node, formatValue) {
|
|
4385
|
+
const rgba = parseCss(formatValue);
|
|
4386
|
+
if (rgba) {
|
|
4387
|
+
const hsl = rgb2Hsl(rgba);
|
|
4388
|
+
if (hsl.l > 50) {
|
|
4389
|
+
hsl.l -= 10;
|
|
4390
|
+
}
|
|
4391
|
+
else {
|
|
4392
|
+
hsl.l += Math.max((50 - hsl.l) * 0.55, 10);
|
|
4393
|
+
}
|
|
4394
|
+
hsl.s *= 0.7;
|
|
4395
|
+
const newRgba = hsl2Rgb(hsl);
|
|
4396
|
+
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a || 1})`);
|
|
4397
|
+
}
|
|
4398
|
+
node.styles.set('backgroundColor', formatValue);
|
|
4399
|
+
}
|
|
4400
|
+
});
|
|
4401
|
+
const cellBackgroundAttrLoader = {
|
|
4402
|
+
match(element) {
|
|
4403
|
+
return (element.tagName === 'TD' || element.tagName === 'TH') && !!element.style.backgroundColor;
|
|
4404
|
+
},
|
|
4405
|
+
read(element) {
|
|
4406
|
+
return {
|
|
4407
|
+
attribute: cellBackgroundAttr,
|
|
4408
|
+
value: element.style.backgroundColor
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
};
|
|
4412
|
+
|
|
3969
4413
|
function CellBackgroundTool() {
|
|
3970
4414
|
const refreshService = inject(RefreshService);
|
|
3971
4415
|
const selection = inject(Selection);
|
|
@@ -3973,16 +4417,24 @@ function CellBackgroundTool() {
|
|
|
3973
4417
|
highlight: false,
|
|
3974
4418
|
disabled: false,
|
|
3975
4419
|
});
|
|
3976
|
-
function
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
4420
|
+
function setColor(picker) {
|
|
4421
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4422
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
4423
|
+
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
4424
|
+
if (slots) {
|
|
4425
|
+
slots.map(i => {
|
|
4426
|
+
return i.cells.filter(t => t.visible).map(i => i.raw.slot);
|
|
4427
|
+
}).flat().forEach(slot => {
|
|
4428
|
+
const rgba = picker.rgba;
|
|
4429
|
+
if (rgba) {
|
|
4430
|
+
slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
|
|
4431
|
+
}
|
|
4432
|
+
else {
|
|
4433
|
+
slot.removeAttribute(cellBackgroundAttr);
|
|
4434
|
+
}
|
|
4435
|
+
});
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
3986
4438
|
}
|
|
3987
4439
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
3988
4440
|
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
@@ -3995,7 +4447,7 @@ function CellBackgroundTool() {
|
|
|
3995
4447
|
});
|
|
3996
4448
|
return () => {
|
|
3997
4449
|
const vm = viewModel();
|
|
3998
|
-
return jsx(Button, { highlight: vm.highlight, disabled: vm.disabled,
|
|
4450
|
+
return (jsx(Dropdown, { width: '177px', menu: jsx(ColorPicker, { onSelected: setColor }), trigger: 'hover', children: jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, children: jsx("span", { class: "xnote-icon-palette" }) }) }));
|
|
3999
4451
|
};
|
|
4000
4452
|
}
|
|
4001
4453
|
|
|
@@ -4312,78 +4764,6 @@ const katexComponentLoader = {
|
|
|
4312
4764
|
}
|
|
4313
4765
|
};
|
|
4314
4766
|
|
|
4315
|
-
function createTimelineItem(textbus, theme) {
|
|
4316
|
-
const slot = new Slot([
|
|
4317
|
-
ContentType.BlockComponent,
|
|
4318
|
-
]);
|
|
4319
|
-
const title = new ParagraphComponent(textbus);
|
|
4320
|
-
title.state.slot.insert('时间主题', [
|
|
4321
|
-
[fontSizeFormatter, '18px'],
|
|
4322
|
-
[boldFormatter, true]
|
|
4323
|
-
]);
|
|
4324
|
-
title.state.slot.insert(' 2020-02-02', [
|
|
4325
|
-
[fontSizeFormatter, '15px'],
|
|
4326
|
-
[colorFormatter, '#777']
|
|
4327
|
-
]);
|
|
4328
|
-
const desc = new ParagraphComponent(textbus);
|
|
4329
|
-
desc.state.slot.insert('描述信息...');
|
|
4330
|
-
slot.insert(title);
|
|
4331
|
-
slot.insert(desc);
|
|
4332
|
-
return { theme, slot };
|
|
4333
|
-
}
|
|
4334
|
-
class TimelineComponent extends Component {
|
|
4335
|
-
static fromJSON(textbus, json) {
|
|
4336
|
-
const registry = textbus.get(Registry);
|
|
4337
|
-
return new TimelineComponent(textbus, {
|
|
4338
|
-
items: json.items.map(i => {
|
|
4339
|
-
return {
|
|
4340
|
-
theme: i.theme,
|
|
4341
|
-
slot: registry.createSlot(i.slot)
|
|
4342
|
-
};
|
|
4343
|
-
})
|
|
4344
|
-
});
|
|
4345
|
-
}
|
|
4346
|
-
getSlots() {
|
|
4347
|
-
return this.state.items.map(i => i.slot);
|
|
4348
|
-
}
|
|
4349
|
-
}
|
|
4350
|
-
TimelineComponent.componentName = 'TimelineComponent';
|
|
4351
|
-
TimelineComponent.type = ContentType.BlockComponent;
|
|
4352
|
-
|
|
4353
|
-
function createStepItem(textbus) {
|
|
4354
|
-
const slot = new Slot([
|
|
4355
|
-
ContentType.BlockComponent
|
|
4356
|
-
]);
|
|
4357
|
-
const title = new ParagraphComponent(textbus);
|
|
4358
|
-
title.state.slot.insert('标题', [
|
|
4359
|
-
[fontSizeFormatter, '18px'],
|
|
4360
|
-
[boldFormatter, true]
|
|
4361
|
-
]);
|
|
4362
|
-
const content = new ParagraphComponent(textbus);
|
|
4363
|
-
content.state.slot.insert('描述信息...');
|
|
4364
|
-
slot.insert(title);
|
|
4365
|
-
slot.insert(content);
|
|
4366
|
-
return { slot };
|
|
4367
|
-
}
|
|
4368
|
-
class StepComponent extends Component {
|
|
4369
|
-
static fromJSON(textbus, json) {
|
|
4370
|
-
const registry = textbus.get(Registry);
|
|
4371
|
-
return new StepComponent(textbus, {
|
|
4372
|
-
step: json.step,
|
|
4373
|
-
items: json.items.map(i => {
|
|
4374
|
-
return {
|
|
4375
|
-
slot: registry.createSlot(i.slot)
|
|
4376
|
-
};
|
|
4377
|
-
})
|
|
4378
|
-
});
|
|
4379
|
-
}
|
|
4380
|
-
getSlots() {
|
|
4381
|
-
return this.state.items.map(i => i.slot);
|
|
4382
|
-
}
|
|
4383
|
-
}
|
|
4384
|
-
StepComponent.componentName = 'StepComponent';
|
|
4385
|
-
StepComponent.type = ContentType.BlockComponent;
|
|
4386
|
-
|
|
4387
4767
|
function InsertTool(props) {
|
|
4388
4768
|
const commander = inject(Commander);
|
|
4389
4769
|
const selection = inject(Selection);
|
|
@@ -4993,7 +5373,7 @@ const Toolbar = withAnnotation({
|
|
|
4993
5373
|
opacity: p.opacity,
|
|
4994
5374
|
display: editorService.hideInlineToolbar ? 'none' : '',
|
|
4995
5375
|
transitionDuration: p.transitionDuration + 's'
|
|
4996
|
-
}, children: [selection.commonAncestorComponent instanceof TableComponent && jsxs(Fragment$1, { children: [jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table"), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(ToolbarItem, { children: jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(ColorTool, {}) })] }));
|
|
5376
|
+
}, children: [selection.commonAncestorComponent instanceof TableComponent && jsxs(Fragment$1, { children: [jsx(ToolbarItem, { children: jsx(MergeCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(SplitCellsTool, {}) }), jsx(ToolbarItem, { children: jsx(CellBackgroundTool, {}) }), jsx(ToolbarItem, { children: jsx(CellAlignTool, {}) })] }, "table"), jsx(ToolbarItem, { children: jsx(BlockTool, {}) }), jsx(ToolbarItem, { children: jsx(AttrTool, {}) }), jsx(ToolbarItem, { children: jsx(BoldTool, {}) }), jsx(ToolbarItem, { children: jsx(ItalicTool, {}) }), jsx(ToolbarItem, { children: jsx(StrikeThroughTool, {}) }), jsx(ToolbarItem, { children: jsx(UnderlineTool, {}) }), jsx(ToolbarItem, { children: jsx(FontSizeTool, {}) }), jsx(ToolbarItem, { children: jsx(FontFamilyTool, {}) }), jsx(ToolbarItem, { children: jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsx(ToolbarItem, { children: jsx(CodeTool, {}) }), jsx(ToolbarItem, { children: jsx(ColorTool, {}) })] }));
|
|
4997
5377
|
});
|
|
4998
5378
|
});
|
|
4999
5379
|
|
|
@@ -6044,7 +6424,9 @@ const TableComponentView = withAnnotation({
|
|
|
6044
6424
|
], children: [jsx("colgroup", { children: state.columnsConfig.map(w => {
|
|
6045
6425
|
return jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
6046
6426
|
}) }), jsx("tbody", { children: normalizedData.map((row) => {
|
|
6047
|
-
return (jsx("tr", { children: row.cells.
|
|
6427
|
+
return (jsx("tr", { children: row.cells.filter(i => {
|
|
6428
|
+
return i.visible;
|
|
6429
|
+
}).map(cell => {
|
|
6048
6430
|
return adapter.slotRender(cell.raw.slot, children => {
|
|
6049
6431
|
return createVNode('td', {
|
|
6050
6432
|
key: cell.raw.id,
|
|
@@ -6111,6 +6493,9 @@ const tableComponentLoader = {
|
|
|
6111
6493
|
ContentType.Text
|
|
6112
6494
|
]), cell).toDelta();
|
|
6113
6495
|
const results = deltaToBlock(delta, textbus);
|
|
6496
|
+
delta.attributes.forEach((value, key) => {
|
|
6497
|
+
slot.setAttribute(key, value);
|
|
6498
|
+
});
|
|
6114
6499
|
results.forEach(i => {
|
|
6115
6500
|
slot.insert(i);
|
|
6116
6501
|
});
|
|
@@ -6139,6 +6524,9 @@ const tableComponentLoader = {
|
|
|
6139
6524
|
ContentType.Text
|
|
6140
6525
|
]), cell).toDelta();
|
|
6141
6526
|
const results = deltaToBlock(delta, textbus);
|
|
6527
|
+
delta.attributes.forEach((value, key) => {
|
|
6528
|
+
slot.setAttribute(key, value);
|
|
6529
|
+
});
|
|
6142
6530
|
results.forEach(i => {
|
|
6143
6531
|
slot.insert(i);
|
|
6144
6532
|
});
|
|
@@ -6439,6 +6827,7 @@ class Editor extends Textbus {
|
|
|
6439
6827
|
strikeThroughFormatLoader,
|
|
6440
6828
|
underlineFormatLoader
|
|
6441
6829
|
], attributeLoaders: [
|
|
6830
|
+
cellBackgroundAttrLoader,
|
|
6442
6831
|
cellAlignAttrLoader,
|
|
6443
6832
|
headingAttrLoader,
|
|
6444
6833
|
textAlignAttrLoader,
|
|
@@ -6526,6 +6915,7 @@ class Editor extends Textbus {
|
|
|
6526
6915
|
strikeThroughFormatter,
|
|
6527
6916
|
underlineFormatter
|
|
6528
6917
|
], attributes: [
|
|
6918
|
+
cellBackgroundAttr,
|
|
6529
6919
|
cellAlignAttr,
|
|
6530
6920
|
headingAttr,
|
|
6531
6921
|
textAlignAttr,
|
|
@@ -6586,4 +6976,4 @@ class Editor extends Textbus {
|
|
|
6586
6976
|
}
|
|
6587
6977
|
}
|
|
6588
6978
|
|
|
6589
|
-
export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CodeTool, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Popup, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, StrikeThroughTool, TableComponent, TableComponentView, TodolistComponent, TodolistView, Toolbar, ToolbarItem, ToolbarPlugin, UnderlineTool, VideoComponent, VideoView, XNoteMessageBug, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };
|
|
6979
|
+
export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CodeTool, ColorPicker, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Picker, Popup, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, StrikeThroughTool, TableComponent, TableComponentView, TodolistComponent, TodolistView, Toolbar, ToolbarItem, ToolbarPlugin, UnderlineTool, VideoComponent, VideoView, XNoteMessageBug, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, cellBackgroundAttr, cellBackgroundAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };
|