@textbus/xnote 0.0.1-alpha.5 → 0.0.1-alpha.7

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/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 css$j = undefined;
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(css$j, () => {
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 css$i = undefined;
147
+ var scopedId$j = "vf-ac7e8d";
158
148
 
159
149
  function ComponentToolbar(props) {
160
- return scopedCss.withScopedCSS(css$i, () => {
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 css$h = undefined;
160
+ var scopedId$i = "vf-ede279";
171
161
 
172
162
  function Divider() {
173
- return scopedCss.withScopedCSS(css$h, () => {
163
+ return scopedCss.withScopedCSS(scopedId$i, () => {
174
164
  return jsxRuntime.jsx("div", { class: "divider" });
175
165
  });
176
166
  }
177
167
 
178
- var style = undefined;
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(style, () => {
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 css$g = undefined;
283
+ var scopedId$g = "vf-a99c5e";
294
284
 
295
- var css$f = undefined;
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(css$f, () => {
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(css$g, () => {
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 css$e = undefined;
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(css$e, () => {
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 css$d = undefined;
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(css$d, () => {
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 css$c = undefined;
489
+ var scopedId$c = "vf-216815";
500
490
 
501
491
  function ToolbarItem(props) {
502
- return scopedCss.withScopedCSS(css$c, () => {
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 css$b = undefined;
497
+ var scopedId$b = "vf-2a8a65";
508
498
 
509
499
  exports.RefreshService = class RefreshService {
510
500
  constructor() {
@@ -560,6 +550,12 @@ function useReadonly() {
560
550
  return is;
561
551
  }
562
552
 
553
+ const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
554
+
555
+ function useOutput() {
556
+ return core.createSignal(core.inject(OutputInjectionToken));
557
+ }
558
+
563
559
  class ParagraphComponent extends core$1.Component {
564
560
  static fromJSON(textbus, json) {
565
561
  const slot = textbus.get(core$1.Registry).createSlot(json.slot);
@@ -595,11 +591,12 @@ ParagraphComponent.type = core$1.ContentType.BlockComponent;
595
591
  function ParagraphView(props) {
596
592
  const adapter = core.inject(platformBrowser.DomAdapter);
597
593
  const readonly = useReadonly();
594
+ const output = useOutput();
598
595
  return () => {
599
596
  const slot = props.component.state.slot;
600
597
  return (jsxRuntime.jsx("div", { class: "xnote-paragraph", ref: props.rootRef, "data-component": ParagraphComponent.name, children: adapter.slotRender(slot, children => {
601
598
  return (core$1.createVNode('p', null, children));
602
- }, readonly()) }));
599
+ }, readonly() || output()) }));
603
600
  };
604
601
  }
605
602
  const paragraphComponentLoader = {
@@ -607,11 +604,12 @@ const paragraphComponentLoader = {
607
604
  return element.dataset.compoment === ParagraphComponent.name || /P|H[1-6]/.test(element.tagName);
608
605
  },
609
606
  read(element, textbus, slotParser) {
607
+ const content = /P|H[1-6]/.test(element.tagName) ? element : element.children[0];
610
608
  const delta = slotParser(new core$1.Slot([
611
609
  core$1.ContentType.Text,
612
610
  core$1.ContentType.InlineComponent,
613
611
  core$1.ContentType.BlockComponent
614
- ]), /P|H[1-6]/.test(element.tagName) ? element : element.children[0]).toDelta();
612
+ ]), content).toDelta();
615
613
  const results = deltaToBlock(delta, textbus);
616
614
  if (results.length === 1) {
617
615
  return results[0];
@@ -652,12 +650,6 @@ function deltaToBlock(delta, textbus) {
652
650
  return results;
653
651
  }
654
652
 
655
- const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
656
-
657
- function useOutput() {
658
- return core.createSignal(core.inject(OutputInjectionToken));
659
- }
660
-
661
653
  const languageList = [{
662
654
  label: 'JavaScript',
663
655
  value: 'JavaScript',
@@ -1091,7 +1083,7 @@ function SourceCodeView(props) {
1091
1083
  'xnote-source-code': true,
1092
1084
  'xnote-source-code-line-number': state.lineNumber,
1093
1085
  [state.theme || 'github']: true
1094
- }, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [(!readonly() && !output()) && jsxRuntime.jsxs(ComponentToolbar, { visible: isFocus(), children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
1086
+ }, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak + '', "data-theme": state.theme || null, "data-line-number": state.lineNumber + '', children: [(!readonly() && !output()) && jsxRuntime.jsxs(ComponentToolbar, { visible: isFocus(), children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
1095
1087
  return {
1096
1088
  label: jsxRuntime.jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
1097
1089
  value: item.value
@@ -1149,7 +1141,7 @@ function SourceCodeView(props) {
1149
1141
  }
1150
1142
  const sourceCodeComponentLoader = {
1151
1143
  match(element) {
1152
- return element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName ||
1144
+ return (element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
1153
1145
  element.tagName === 'PRE';
1154
1146
  },
1155
1147
  read(el, textbus) {
@@ -1178,8 +1170,8 @@ const sourceCodeComponentLoader = {
1178
1170
  return new SourceCodeComponent(textbus, {
1179
1171
  lang: el.dataset.lang || '',
1180
1172
  theme: el.dataset.theme || '',
1181
- lineNumber: !!el.dataset.lineNumber || true,
1182
- autoBreak: !!el.dataset.autoBreak || true,
1173
+ lineNumber: el.dataset.lineNumber === 'true',
1174
+ autoBreak: el.dataset.autoBreak === 'true',
1183
1175
  slots
1184
1176
  });
1185
1177
  },
@@ -1333,7 +1325,7 @@ function AttrTool(props) {
1333
1325
  break;
1334
1326
  }
1335
1327
  }
1336
- return scopedCss.withScopedCSS(css$b, () => {
1328
+ return scopedCss.withScopedCSS(scopedId$b, () => {
1337
1329
  const states = checkStates();
1338
1330
  return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
1339
1331
  {
@@ -1369,12 +1361,18 @@ const headingAttr = new core$1.Attribute('Heading', {
1369
1361
  });
1370
1362
  const headingAttrLoader = {
1371
1363
  match(element) {
1372
- return /H[1-6]/.test(element.tagName);
1364
+ return /H[1-6]/.test(element.tagName) || /(^|\s)xnote-h[1-6](\s|$)/.test(element.className);
1373
1365
  },
1374
1366
  read(element) {
1367
+ if (/H[1-6]/.test(element.tagName)) {
1368
+ return {
1369
+ attribute: headingAttr,
1370
+ value: element.tagName.toLowerCase()
1371
+ };
1372
+ }
1375
1373
  return {
1376
1374
  attribute: headingAttr,
1377
- value: element.tagName.toLowerCase()
1375
+ value: element.className.substring(6)
1378
1376
  };
1379
1377
  }
1380
1378
  };
@@ -1637,7 +1635,7 @@ function registerStrikeThroughShortcut(textbus) {
1637
1635
  }
1638
1636
  const strikeThroughFormatLoader = {
1639
1637
  match(element) {
1640
- return /strike|del|s/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
1638
+ return /^(strike|del|s)$/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
1641
1639
  },
1642
1640
  read() {
1643
1641
  return {
@@ -1755,7 +1753,7 @@ function TodolistView(props) {
1755
1753
  return core$1.createVNode('div', {
1756
1754
  class: 'xnote-todolist-content'
1757
1755
  }, children);
1758
- }, readonly())] }));
1756
+ }, readonly() || output())] }));
1759
1757
  };
1760
1758
  }
1761
1759
  const todolistComponentLoader = {
@@ -1812,11 +1810,12 @@ BlockquoteComponent.zenCoding = {
1812
1810
  function BlockquoteView(props) {
1813
1811
  const adapter = core.inject(platformBrowser.DomAdapter);
1814
1812
  const readonly = useReadonly();
1813
+ const output = useOutput();
1815
1814
  return () => {
1816
1815
  const slot = props.component.state.slot;
1817
1816
  return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: adapter.slotRender(slot, children => {
1818
1817
  return core$1.createVNode('div', null, children);
1819
- }, readonly()) }));
1818
+ }, readonly() || output()) }));
1820
1819
  };
1821
1820
  }
1822
1821
  const blockquoteComponentLoader = {
@@ -1923,6 +1922,25 @@ class ListComponent extends core$1.Component {
1923
1922
  selection.setPosition(slot, 0);
1924
1923
  }
1925
1924
  });
1925
+ core$1.useDynamicShortcut({
1926
+ keymap: {
1927
+ key: 'Tab'
1928
+ },
1929
+ action: () => {
1930
+ updateAfterList(this);
1931
+ return false;
1932
+ }
1933
+ });
1934
+ core$1.useDynamicShortcut({
1935
+ keymap: {
1936
+ key: 'Tab',
1937
+ shiftKey: true
1938
+ },
1939
+ action: () => {
1940
+ Promise.resolve().then(() => updateAfterList(this));
1941
+ return false;
1942
+ }
1943
+ });
1926
1944
  }
1927
1945
  }
1928
1946
  ListComponent.componentName = 'ListComponent';
@@ -2037,7 +2055,7 @@ function ListComponentView(props) {
2037
2055
  return core$1.createVNode('div', {
2038
2056
  class: 'xnote-list-content'
2039
2057
  }, children);
2040
- }, readonly())] }) }));
2058
+ }, readonly() || output())] }) }));
2041
2059
  };
2042
2060
  }
2043
2061
  const listComponentLoader = {
@@ -2177,7 +2195,7 @@ function HighlightBoxView(props) {
2177
2195
  return core$1.createVNode('div', {
2178
2196
  class: 'xnote-highlight-box-content'
2179
2197
  }, children);
2180
- }, readonly())] }));
2198
+ }, readonly() || output())] }));
2181
2199
  }
2182
2200
  return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "260px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [HighlightBoxComponent.defaultTypes.map(icon => {
2183
2201
  return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
@@ -2188,7 +2206,7 @@ function HighlightBoxView(props) {
2188
2206
  return core$1.createVNode('div', {
2189
2207
  class: 'xnote-highlight-box-content'
2190
2208
  }, children);
2191
- }, readonly())] }));
2209
+ }, readonly() || output())] }));
2192
2210
  };
2193
2211
  }
2194
2212
  const highlightBoxComponentLoader = {
@@ -2236,17 +2254,16 @@ function useBlockTransform() {
2236
2254
  commander.unApplyAttribute(headingAttr);
2237
2255
  commander.transform({
2238
2256
  targetType: ParagraphComponent.type,
2239
- multipleSlot: false,
2240
2257
  slotFactory() {
2241
2258
  return new core$1.Slot([
2242
2259
  core$1.ContentType.InlineComponent,
2243
2260
  core$1.ContentType.Text
2244
2261
  ]);
2245
2262
  },
2246
- stateFactory(slot) {
2247
- return new ParagraphComponent(textbus, {
2263
+ stateFactory(slots) {
2264
+ return slots.map(slot => new ParagraphComponent(textbus, {
2248
2265
  slot
2249
- });
2266
+ }));
2250
2267
  }
2251
2268
  });
2252
2269
  break;
@@ -2265,17 +2282,18 @@ function useBlockTransform() {
2265
2282
  commander.unApplyAttribute(headingAttr);
2266
2283
  commander.transform({
2267
2284
  targetType: TodolistComponent.type,
2268
- multipleSlot: false,
2269
2285
  slotFactory() {
2270
2286
  return new core$1.Slot([
2271
2287
  core$1.ContentType.InlineComponent,
2272
2288
  core$1.ContentType.Text
2273
2289
  ]);
2274
2290
  },
2275
- stateFactory(slot) {
2276
- return new TodolistComponent(textbus, {
2277
- checked: false,
2278
- slot
2291
+ stateFactory(slots) {
2292
+ return slots.map(slot => {
2293
+ return new TodolistComponent(textbus, {
2294
+ checked: false,
2295
+ slot
2296
+ });
2279
2297
  });
2280
2298
  }
2281
2299
  });
@@ -2285,18 +2303,19 @@ function useBlockTransform() {
2285
2303
  {
2286
2304
  commander.transform({
2287
2305
  targetType: ListComponent.type,
2288
- multipleSlot: false,
2289
2306
  slotFactory() {
2290
2307
  return new core$1.Slot([
2291
2308
  core$1.ContentType.InlineComponent,
2292
2309
  core$1.ContentType.Text
2293
2310
  ]);
2294
2311
  },
2295
- stateFactory(slot) {
2296
- return new ListComponent(textbus, {
2297
- type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
2298
- reorder: true,
2299
- slot
2312
+ stateFactory(slots) {
2313
+ return slots.map((slot, index) => {
2314
+ return new ListComponent(textbus, {
2315
+ type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
2316
+ reorder: index === 0,
2317
+ slot
2318
+ });
2300
2319
  });
2301
2320
  }
2302
2321
  });
@@ -2344,16 +2363,17 @@ function useBlockTransform() {
2344
2363
  if (state.state === core$1.QueryStateType.Enabled) {
2345
2364
  commander.transform({
2346
2365
  targetType: ParagraphComponent.type,
2347
- multipleSlot: false,
2348
2366
  slotFactory() {
2349
2367
  return new core$1.Slot([
2350
2368
  core$1.ContentType.InlineComponent,
2351
2369
  core$1.ContentType.Text
2352
2370
  ]);
2353
2371
  },
2354
- stateFactory(slot) {
2355
- return new ParagraphComponent(textbus, {
2356
- slot
2372
+ stateFactory(slots) {
2373
+ return slots.map(slot => {
2374
+ return new ParagraphComponent(textbus, {
2375
+ slot
2376
+ });
2357
2377
  });
2358
2378
  }
2359
2379
  });
@@ -2361,24 +2381,23 @@ function useBlockTransform() {
2361
2381
  else {
2362
2382
  commander.transform({
2363
2383
  targetType: SourceCodeComponent.type,
2364
- multipleSlot: true,
2365
2384
  slotFactory() {
2366
2385
  return new core$1.Slot([
2367
2386
  core$1.ContentType.Text
2368
2387
  ]);
2369
2388
  },
2370
2389
  stateFactory(slots) {
2371
- return new SourceCodeComponent(textbus, {
2372
- lang: '',
2373
- lineNumber: true,
2374
- autoBreak: true,
2375
- slots: slots.map(slot => {
2376
- return {
2377
- slot,
2378
- emphasize: false
2379
- };
2380
- })
2381
- });
2390
+ return [new SourceCodeComponent(textbus, {
2391
+ lang: '',
2392
+ lineNumber: true,
2393
+ autoBreak: true,
2394
+ slots: slots.map(slot => {
2395
+ return {
2396
+ slot,
2397
+ emphasize: false
2398
+ };
2399
+ })
2400
+ })];
2382
2401
  }
2383
2402
  });
2384
2403
  }
@@ -2427,7 +2446,7 @@ function useBlockTransform() {
2427
2446
  function BlockTool() {
2428
2447
  const checkStates = useActiveBlock();
2429
2448
  const transform = useBlockTransform();
2430
- return scopedCss.withScopedCSS(css$b, () => {
2449
+ return scopedCss.withScopedCSS(scopedId$b, () => {
2431
2450
  const states = checkStates();
2432
2451
  const types = [
2433
2452
  [states.paragraph, 'xnote-icon-pilcrow'],
@@ -2858,7 +2877,7 @@ function CodeTool() {
2858
2877
  };
2859
2878
  }
2860
2879
 
2861
- var css$a = undefined;
2880
+ var scopedId$a = "vf-1fbbdf";
2862
2881
 
2863
2882
  function ColorTool(props) {
2864
2883
  const query = core.inject(core$1.Query);
@@ -2893,6 +2912,7 @@ function ColorTool(props) {
2893
2912
  '#ffdf14',
2894
2913
  '#5eec75',
2895
2914
  '#5dfaff',
2915
+ '#1296db',
2896
2916
  '#617fff',
2897
2917
  '#c459ff',
2898
2918
  ];
@@ -2906,7 +2926,7 @@ function ColorTool(props) {
2906
2926
  '#90a0e5',
2907
2927
  '#c596e0',
2908
2928
  ];
2909
- return scopedCss.withScopedCSS(css$a, () => {
2929
+ return scopedCss.withScopedCSS(scopedId$a, () => {
2910
2930
  const vm = viewModel();
2911
2931
  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
2932
  active: textColor() === ''
@@ -3114,7 +3134,7 @@ function ItalicTool() {
3114
3134
  };
3115
3135
  }
3116
3136
 
3117
- var css$9 = undefined;
3137
+ var scopedId$9 = "vf-269a0b";
3118
3138
 
3119
3139
  function LinkTool(props) {
3120
3140
  const selectionBridge = core.inject(platformBrowser.SelectionBridge);
@@ -3145,7 +3165,7 @@ function LinkTool(props) {
3145
3165
  core.onUnmounted(() => {
3146
3166
  sub.unsubscribe();
3147
3167
  });
3148
- return scopedCss.withScopedCSS(css$9, () => {
3168
+ return scopedCss.withScopedCSS(scopedId$9, () => {
3149
3169
  const containerRect = container.getBoundingClientRect();
3150
3170
  const rect = isShow() ? selectionBridge.getRect({
3151
3171
  slot: selection.focusSlot,
@@ -3214,12 +3234,93 @@ function UnderlineTool() {
3214
3234
  };
3215
3235
  }
3216
3236
 
3217
- var css$8 = undefined;
3237
+ var scopedId$8 = "vf-cf8e1c";
3238
+
3239
+ class FileUploader {
3240
+ }
3241
+
3242
+ class ImageComponent extends core$1.Component {
3243
+ static fromJSON(textbus, json) {
3244
+ return new ImageComponent(textbus, Object.assign({}, json));
3245
+ }
3246
+ }
3247
+ ImageComponent.type = core$1.ContentType.InlineComponent;
3248
+ ImageComponent.componentName = 'ImageComponent';
3249
+ function ImageView(props) {
3250
+ const { name, state } = props.component;
3251
+ const imageRef = core.createRef();
3252
+ const readonly = useReadonly();
3253
+ const output = useOutput();
3254
+ return () => {
3255
+ if (readonly() || output()) {
3256
+ return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
3257
+ width: state.width,
3258
+ height: state.height
3259
+ } }) }));
3260
+ }
3261
+ 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: {
3262
+ width: state.width,
3263
+ height: state.height
3264
+ } }) }) }));
3265
+ };
3266
+ }
3267
+ const imageComponentLoader = {
3268
+ match(element) {
3269
+ return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
3270
+ },
3271
+ read(element, textbus) {
3272
+ var _a;
3273
+ return new ImageComponent(textbus, {
3274
+ src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('img')) === null || _a === void 0 ? void 0 : _a.src) || ''
3275
+ });
3276
+ }
3277
+ };
3278
+
3279
+ class VideoComponent extends core$1.Component {
3280
+ static fromJSON(textbus, json) {
3281
+ return new VideoComponent(textbus, Object.assign({}, json));
3282
+ }
3283
+ setup() {
3284
+ //
3285
+ }
3286
+ }
3287
+ VideoComponent.type = core$1.ContentType.InlineComponent;
3288
+ VideoComponent.componentName = 'VideoComponent';
3289
+ function VideoView(props) {
3290
+ const { name, state } = props.component;
3291
+ const videoRef = core.createRef();
3292
+ const readonly = useReadonly();
3293
+ const output = useOutput();
3294
+ return () => {
3295
+ if (readonly() || output()) {
3296
+ return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
3297
+ width: state.width,
3298
+ height: state.height
3299
+ } }) }));
3300
+ }
3301
+ 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: {
3302
+ width: state.width,
3303
+ height: state.height
3304
+ } }) }) }));
3305
+ };
3306
+ }
3307
+ const videoComponentLoader = {
3308
+ match(element) {
3309
+ return element.tagName === 'IMG' || element.dataset.component === VideoComponent.componentName;
3310
+ },
3311
+ read(element, textbus) {
3312
+ var _a;
3313
+ return new VideoComponent(textbus, {
3314
+ src: element instanceof HTMLImageElement ? element.src : ((_a = element.querySelector('video')) === null || _a === void 0 ? void 0 : _a.src) || ''
3315
+ });
3316
+ }
3317
+ };
3218
3318
 
3219
3319
  function InsertTool(props) {
3220
3320
  const commander = core.inject(core$1.Commander);
3221
3321
  const selection = core.inject(core$1.Selection);
3222
3322
  const textbus = core.inject(core$1.Textbus);
3323
+ const fileUploader = core.inject(FileUploader, core.InjectFlags.Optional, null);
3223
3324
  function insert(type) {
3224
3325
  var _a;
3225
3326
  const component = (_a = props.slot) === null || _a === void 0 ? void 0 : _a.parent;
@@ -3312,8 +3413,24 @@ function InsertTool(props) {
3312
3413
  }
3313
3414
  break;
3314
3415
  case 'image':
3416
+ if (fileUploader) {
3417
+ Promise.resolve(fileUploader.uploadFile('image')).then(url => {
3418
+ const img = new ImageComponent(textbus, {
3419
+ src: url
3420
+ });
3421
+ commander.insert(img);
3422
+ });
3423
+ }
3315
3424
  break;
3316
3425
  case 'video':
3426
+ if (fileUploader) {
3427
+ Promise.resolve(fileUploader.uploadFile('video')).then(url => {
3428
+ const img = new VideoComponent(textbus, {
3429
+ src: url
3430
+ });
3431
+ commander.insert(img);
3432
+ });
3433
+ }
3317
3434
  break;
3318
3435
  case 'highlightBox':
3319
3436
  {
@@ -3326,12 +3443,12 @@ function InsertTool(props) {
3326
3443
  break;
3327
3444
  }
3328
3445
  }
3329
- return scopedCss.withScopedCSS(css$8, () => {
3446
+ return scopedCss.withScopedCSS(scopedId$8, () => {
3330
3447
  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
3448
  });
3332
3449
  }
3333
3450
 
3334
- var css$7 = undefined;
3451
+ var scopedId$7 = "vf-b05292";
3335
3452
 
3336
3453
  const LeftToolbar = core.withAnnotation({
3337
3454
  providers: [exports.RefreshService]
@@ -3494,7 +3611,7 @@ const LeftToolbar = core.withAnnotation({
3494
3611
  function changeIgnoreMove(b) {
3495
3612
  isIgnoreMove = b;
3496
3613
  }
3497
- return scopedCss.withScopedCSS(css$7, () => {
3614
+ return scopedCss.withScopedCSS(scopedId$7, () => {
3498
3615
  const position = positionSignal();
3499
3616
  const slot = activeSlot();
3500
3617
  let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
@@ -3568,7 +3685,7 @@ class LeftToolbarPlugin {
3568
3685
  }
3569
3686
  }
3570
3687
 
3571
- var css$6 = undefined;
3688
+ var scopedId$6 = "vf-fee98b";
3572
3689
 
3573
3690
  exports.EditorService = class EditorService {
3574
3691
  constructor() {
@@ -3678,7 +3795,7 @@ const Toolbar = core.withAnnotation({
3678
3795
  mousedownSubscription.unsubscribe();
3679
3796
  mouseupSubscription.unsubscribe();
3680
3797
  });
3681
- return scopedCss.withScopedCSS(css$6, () => {
3798
+ return scopedCss.withScopedCSS(scopedId$6, () => {
3682
3799
  const p = viewPosition();
3683
3800
  return (jsxRuntime.jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
3684
3801
  left: p.left + 'px',
@@ -3813,72 +3930,35 @@ class Matcher {
3813
3930
  }
3814
3931
  }
3815
3932
 
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
3933
  class RootComponent extends core$1.Component {
3854
3934
  constructor() {
3855
3935
  super(...arguments);
3856
3936
  this.onCompositionStart = new core$1.Subject();
3857
3937
  }
3858
3938
  static fromJSON(textbus, json) {
3859
- const heading = textbus.get(core$1.Registry).createSlot(json.heading);
3939
+ // const heading = textbus.get(Registry).createSlot(json.heading)
3860
3940
  const content = textbus.get(core$1.Registry).createSlot(json.content);
3861
3941
  return new RootComponent(textbus, {
3862
- heading,
3942
+ // heading,
3863
3943
  content
3864
3944
  });
3865
3945
  }
3866
3946
  setup() {
3867
- const textbus = core$1.useContext();
3868
- const selection = textbus.get(core$1.Selection);
3869
- core$1.onBreak(ev => {
3870
- if (ev.target === this.state.heading) {
3871
- const afterContent = ev.target.cut(ev.data.index);
3872
- const p = new ParagraphComponent(textbus, {
3873
- slot: afterContent
3874
- });
3875
- const body = this.state.content;
3876
- body.retain(0);
3877
- body.insert(p);
3878
- selection.setPosition(afterContent, 0);
3879
- ev.preventDefault();
3880
- }
3881
- });
3947
+ // const textbus = useContext()
3948
+ // const selection = textbus.get(Selection)
3949
+ // onBreak(ev => {
3950
+ // if (ev.target === this.state.heading) {
3951
+ // const afterContent = ev.target.cut(ev.data.index)
3952
+ // const p = new ParagraphComponent(textbus, {
3953
+ // slot: afterContent
3954
+ // })
3955
+ // const body = this.state.content
3956
+ // body.retain(0)
3957
+ // body.insert(p)
3958
+ // selection.setPosition(afterContent, 0)
3959
+ // ev.preventDefault()
3960
+ // }
3961
+ // })
3882
3962
  useBlockContent(this.state.content);
3883
3963
  core$1.onCompositionStart(ev => {
3884
3964
  this.onCompositionStart.next(ev);
@@ -3900,37 +3980,28 @@ RootComponent.componentName = 'RootComponent';
3900
3980
  RootComponent.type = core$1.ContentType.BlockComponent;
3901
3981
  function RootView(props) {
3902
3982
  const adapter = core.inject(platformBrowser.DomAdapter);
3903
- const { heading, content } = props.component.state;
3983
+ const { content } = props.component.state;
3904
3984
  const ref = core.createDynamicRef(node => {
3905
- const sub = props.component.onCompositionStart.subscribe(ev => {
3906
- if (ev.target === heading) {
3907
- node.children[0].dataset.placeholder = '';
3908
- }
3909
- else {
3910
- node.children[1].dataset.placeholder = '';
3911
- }
3985
+ const sub = props.component.onCompositionStart.subscribe(() => {
3986
+ node.children[0].dataset.placeholder = '';
3912
3987
  });
3913
3988
  return () => {
3914
3989
  sub.unsubscribe();
3915
3990
  };
3916
3991
  });
3917
- core.onUpdated(() => {
3918
- props.component.afterCheck();
3919
- });
3992
+ // onUpdated(() => {
3993
+ // props.component.afterCheck()
3994
+ // })
3920
3995
  const readonly = useReadonly();
3996
+ const output = useOutput();
3921
3997
  return () => {
3922
3998
  const { rootRef } = props;
3923
- return (jsxRuntime.jsxs("div", { class: "xnote-root", ref: [rootRef, ref], children: [adapter.slotRender(heading, children => {
3924
- return (core$1.createVNode('div', {
3925
- class: 'xnote-title',
3926
- 'data-placeholder': heading.isEmpty ? '请输入标题' : ''
3927
- }, children));
3928
- }, readonly()), adapter.slotRender(content, children => {
3929
- return (core$1.createVNode('div', {
3930
- class: 'xnote-content',
3931
- 'data-placeholder': content.isEmpty ? '请输入内容' : ''
3932
- }, children));
3933
- }, readonly())] }));
3999
+ return (jsxRuntime.jsx("div", { class: "xnote-root", ref: [rootRef, ref], children: adapter.slotRender(content, children => {
4000
+ return (core$1.createVNode('div', {
4001
+ class: 'xnote-content',
4002
+ 'data-placeholder': content.isEmpty ? '请输入内容' : ''
4003
+ }, children));
4004
+ }, readonly() || output()) }));
3934
4005
  };
3935
4006
  }
3936
4007
  const rootComponentLoader = {
@@ -3955,7 +4026,7 @@ const rootComponentLoader = {
3955
4026
  }
3956
4027
  };
3957
4028
 
3958
- var css$5 = undefined;
4029
+ var scopedId$5 = "vf-681de2";
3959
4030
 
3960
4031
  let TableService = class TableService {
3961
4032
  constructor() {
@@ -4042,12 +4113,12 @@ function ResizeColumn(props) {
4042
4113
  });
4043
4114
  return () => sub.unsubscribe();
4044
4115
  });
4045
- return scopedCss.withScopedCSS(css$5, () => {
4116
+ return scopedCss.withScopedCSS(scopedId$5, () => {
4046
4117
  return jsxRuntime.jsx("div", { ref: dragLineRef, class: ['drag-line'] });
4047
4118
  });
4048
4119
  }
4049
4120
 
4050
- var css$4 = undefined;
4121
+ var scopedId$4 = "vf-d64cf9";
4051
4122
 
4052
4123
  function TopBar(props) {
4053
4124
  const editorService = core.inject(exports.EditorService);
@@ -4115,7 +4186,7 @@ function TopBar(props) {
4115
4186
  s.unsubscribe();
4116
4187
  });
4117
4188
  const deleteIndex = core.createSignal(null);
4118
- return scopedCss.withScopedCSS(css$4, () => {
4189
+ return scopedCss.withScopedCSS(scopedId$4, () => {
4119
4190
  const { state, tableSelection } = props.component;
4120
4191
  const position = tableSelection();
4121
4192
  return (jsxRuntime.jsx("div", { class: ['top-bar', {
@@ -4168,7 +4239,7 @@ function TopBar(props) {
4168
4239
  });
4169
4240
  }
4170
4241
 
4171
- var css$3 = undefined;
4242
+ var scopedId$3 = "vf-b1149b";
4172
4243
 
4173
4244
  function Scroll(props) {
4174
4245
  const scrollRef = core.createRef();
@@ -4200,7 +4271,7 @@ function Scroll(props) {
4200
4271
  draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
4201
4272
  });
4202
4273
  });
4203
- return scopedCss.withScopedCSS(css$3, () => {
4274
+ return scopedCss.withScopedCSS(scopedId$3, () => {
4204
4275
  return jsxRuntime.jsx("div", { ref: [scrollRef, props.scrollRef], class: ['scroll-container', {
4205
4276
  'left-end': showShadow().leftEnd,
4206
4277
  'right-end': showShadow().rightEnd,
@@ -4212,7 +4283,7 @@ function Scroll(props) {
4212
4283
  });
4213
4284
  }
4214
4285
 
4215
- var css$2 = undefined;
4286
+ var scopedId$2 = "vf-ef93c0";
4216
4287
 
4217
4288
  function LeftBar(props) {
4218
4289
  const editorService = core.inject(exports.EditorService);
@@ -4286,7 +4357,7 @@ function LeftBar(props) {
4286
4357
  textbus.focus();
4287
4358
  });
4288
4359
  }
4289
- return scopedCss.withScopedCSS(css$2, () => {
4360
+ return scopedCss.withScopedCSS(scopedId$2, () => {
4290
4361
  const { state, tableSelection } = props.component;
4291
4362
  const position = tableSelection();
4292
4363
  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 +4405,7 @@ function LeftBar(props) {
4334
4405
  });
4335
4406
  }
4336
4407
 
4337
- var css$1 = undefined;
4408
+ var scopedId$1 = "vf-d4c4a9";
4338
4409
 
4339
4410
  function sum(numbers) {
4340
4411
  return numbers.reduce((a, b) => a + b, 0);
@@ -4367,7 +4438,7 @@ function ResizeRow(props) {
4367
4438
  });
4368
4439
  return () => sub.unsubscribe();
4369
4440
  });
4370
- return scopedCss.withScopedCSS(css$1, () => {
4441
+ return scopedCss.withScopedCSS(scopedId$1, () => {
4371
4442
  return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
4372
4443
  display: styles().visible ? 'block' : 'none',
4373
4444
  top: styles().top + 'px',
@@ -4376,7 +4447,7 @@ function ResizeRow(props) {
4376
4447
  });
4377
4448
  }
4378
4449
 
4379
- var css = undefined;
4450
+ var scopedId = "vf-4a5ad1";
4380
4451
 
4381
4452
  function SelectionMask(props) {
4382
4453
  const [styles, updateStyles] = hooks.useProduce({
@@ -4429,7 +4500,7 @@ function SelectionMask(props) {
4429
4500
  core.onUnmounted(() => {
4430
4501
  s.unsubscribe();
4431
4502
  });
4432
- return scopedCss.withScopedCSS(css, () => {
4503
+ return scopedCss.withScopedCSS(scopedId, () => {
4433
4504
  const style = styles();
4434
4505
  return (jsxRuntime.jsx("div", { class: "mask", style: {
4435
4506
  display: style.visible ? 'block' : 'none',
@@ -4547,7 +4618,7 @@ const TableComponentView = core.withAnnotation({
4547
4618
  return core$1.createVNode('td', {
4548
4619
  key: cell.slot.id
4549
4620
  }, children);
4550
- }, readonly());
4621
+ }, readonly() || output());
4551
4622
  }) }, rowMapping.get(row)));
4552
4623
  }) })] }) }) }));
4553
4624
  }
@@ -4564,7 +4635,7 @@ const TableComponentView = core.withAnnotation({
4564
4635
  return core$1.createVNode('td', {
4565
4636
  key: cell.slot.id
4566
4637
  }, children);
4567
- }, readonly());
4638
+ }, readonly() || output());
4568
4639
  }) }, rowMapping.get(row)));
4569
4640
  }) })] }), jsxRuntime.jsx(ResizeColumn, { tableRef: tableRef, component: props.component, onActiveStateChange: isActive => {
4570
4641
  isResizeColumn.set(isActive);
@@ -4727,48 +4798,8 @@ function autoComplete(table) {
4727
4798
  });
4728
4799
  }
4729
4800
 
4730
- class VideoComponent extends core$1.Component {
4731
- static fromJSON(textbus, json) {
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 = {}) {
4801
+ class Editor extends core$1.Textbus {
4802
+ constructor(editorConfig = {}) {
4772
4803
  const adapter = new adapterViewfly.ViewflyAdapter({
4773
4804
  [ParagraphComponent.componentName]: ParagraphView,
4774
4805
  [RootComponent.componentName]: RootView,
@@ -4792,6 +4823,38 @@ function createXNote(host_1) {
4792
4823
  app.destroy();
4793
4824
  };
4794
4825
  });
4826
+ const browserModule = new platformBrowser.BrowserModule(Object.assign({ renderTo: () => {
4827
+ return this.host;
4828
+ }, adapter, componentLoaders: [
4829
+ sourceCodeComponentLoader,
4830
+ tableComponentLoader,
4831
+ imageComponentLoader,
4832
+ videoComponentLoader,
4833
+ highlightBoxComponentLoader,
4834
+ blockquoteComponentLoader,
4835
+ paragraphComponentLoader,
4836
+ todolistComponentLoader,
4837
+ listComponentLoader,
4838
+ ], formatLoaders: [
4839
+ backgroundColorFormatLoader,
4840
+ boldFormatLoader,
4841
+ codeFormatLoader,
4842
+ colorFormatLoader,
4843
+ fontFamilyFormatLoader,
4844
+ fontSizeFormatLoader,
4845
+ italicFormatLoader,
4846
+ linkFormatLoader,
4847
+ strikeThroughFormatLoader,
4848
+ underlineFormatLoader
4849
+ ], attributeLoaders: [
4850
+ headingAttrLoader,
4851
+ textAlignAttrLoader,
4852
+ textIndentAttrLoader
4853
+ ] }, editorConfig.viewOptions));
4854
+ const modules = [browserModule];
4855
+ if (editorConfig.collaborateConfig) {
4856
+ modules.push(new collaborate.CollaborateModule(editorConfig.collaborateConfig));
4857
+ }
4795
4858
  const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
4796
4859
  [ParagraphComponent.componentName]: ParagraphView,
4797
4860
  [RootComponent.componentName]: RootView,
@@ -4809,7 +4872,7 @@ function createXNote(host_1) {
4809
4872
  useValue: true
4810
4873
  }, {
4811
4874
  provide: platformBrowser.DomAdapter,
4812
- useFactory() {
4875
+ useFactory: () => {
4813
4876
  return vDomAdapter;
4814
4877
  }
4815
4878
  }]);
@@ -4821,50 +4884,7 @@ function createXNote(host_1) {
4821
4884
  app.destroy();
4822
4885
  };
4823
4886
  });
4824
- const browserModule = new platformBrowser.BrowserModule({
4825
- renderTo() {
4826
- return host;
4827
- },
4828
- adapter,
4829
- componentLoaders: [
4830
- highlightBoxComponentLoader,
4831
- blockquoteComponentLoader,
4832
- paragraphComponentLoader,
4833
- sourceCodeComponentLoader,
4834
- todolistComponentLoader,
4835
- tableComponentLoader,
4836
- listComponentLoader,
4837
- imageComponentLoader,
4838
- videoComponentLoader
4839
- ],
4840
- formatLoaders: [
4841
- backgroundColorFormatLoader,
4842
- boldFormatLoader,
4843
- codeFormatLoader,
4844
- colorFormatLoader,
4845
- fontFamilyFormatLoader,
4846
- fontSizeFormatLoader,
4847
- italicFormatLoader,
4848
- linkFormatLoader,
4849
- strikeThroughFormatLoader,
4850
- underlineFormatLoader
4851
- ],
4852
- attributeLoaders: [
4853
- headingAttrLoader,
4854
- textAlignAttrLoader,
4855
- textIndentAttrLoader
4856
- ]
4857
- });
4858
- const modules = [browserModule];
4859
- if (config.collaborateConfig) {
4860
- modules.push(new collaborate.CollaborateModule(config.collaborateConfig));
4861
- }
4862
- const textbus = new core$1.Textbus({
4863
- additionalAdapters: [vDomAdapter],
4864
- zenCoding: true,
4865
- readonly: config.readonly,
4866
- imports: modules,
4867
- components: [
4887
+ super(Object.assign({ zenCoding: true, additionalAdapters: [vDomAdapter], imports: modules, components: [
4868
4888
  ImageComponent,
4869
4889
  ParagraphComponent,
4870
4890
  RootComponent,
@@ -4875,8 +4895,7 @@ function createXNote(host_1) {
4875
4895
  HighlightBoxComponent,
4876
4896
  ListComponent,
4877
4897
  VideoComponent
4878
- ],
4879
- formatters: [
4898
+ ], formatters: [
4880
4899
  backgroundColorFormatter,
4881
4900
  boldFormatter,
4882
4901
  codeFormatter,
@@ -4887,18 +4906,14 @@ function createXNote(host_1) {
4887
4906
  linkFormatter,
4888
4907
  strikeThroughFormatter,
4889
4908
  underlineFormatter
4890
- ],
4891
- attributes: [
4909
+ ], attributes: [
4892
4910
  headingAttr,
4893
4911
  textAlignAttr,
4894
4912
  textIndentAttr
4895
- ],
4896
- providers: [],
4897
- plugins: [
4913
+ ], plugins: [
4898
4914
  new LeftToolbarPlugin(),
4899
4915
  new ToolbarPlugin(),
4900
- ],
4901
- onAfterStartup(textbus) {
4916
+ ], onAfterStartup(textbus) {
4902
4917
  registerBoldShortcut(textbus);
4903
4918
  registerCodeShortcut(textbus);
4904
4919
  registerItalicShortcut(textbus);
@@ -4907,32 +4922,34 @@ function createXNote(host_1) {
4907
4922
  registerHeadingShortcut(textbus);
4908
4923
  registerTextAlignShortcut(textbus);
4909
4924
  registerTextIndentShortcut(textbus);
4910
- }
4911
- });
4925
+ } }, editorConfig));
4926
+ this.editorConfig = editorConfig;
4927
+ this.translator = new platformBrowser$1.OutputTranslator();
4928
+ this.vDomAdapter = vDomAdapter;
4929
+ }
4930
+ mount(host) {
4931
+ this.host = host;
4912
4932
  let rootComp;
4933
+ const config = this.editorConfig;
4913
4934
  if (config.content) {
4914
- const parser = textbus.get(platformBrowser.Parser);
4935
+ const parser = this.get(platformBrowser.Parser);
4915
4936
  const doc = parser.parseDoc(config.content, rootComponentLoader);
4916
- rootComp = doc instanceof core$1.Component ? doc : new RootComponent(textbus, {
4917
- heading: new core$1.Slot([core$1.ContentType.Text]),
4937
+ rootComp = doc instanceof core$1.Component ? doc : new RootComponent(this, {
4938
+ // heading: new Slot([ContentType.Text]),
4918
4939
  content: doc
4919
4940
  });
4920
4941
  }
4921
4942
  else {
4922
- rootComp = new RootComponent(textbus, {
4923
- heading: new core$1.Slot([core$1.ContentType.Text]),
4943
+ rootComp = new RootComponent(this, {
4944
+ // heading: new Slot([ContentType.Text]),
4924
4945
  content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
4925
4946
  });
4926
4947
  }
4927
- yield textbus.render(rootComp);
4928
- const translator = new platformBrowser$1.OutputTranslator();
4929
- return {
4930
- textbus,
4931
- getHTML() {
4932
- return translator.transform(vDomAdapter.host);
4933
- }
4934
- };
4935
- });
4948
+ return this.render(rootComp);
4949
+ }
4950
+ getHTML() {
4951
+ return this.translator.transform(this.vDomAdapter.host);
4952
+ }
4936
4953
  }
4937
4954
 
4938
4955
  exports.AttrTool = AttrTool;
@@ -4948,6 +4965,7 @@ exports.Divider = Divider;
4948
4965
  exports.DragResize = DragResize;
4949
4966
  exports.Dropdown = Dropdown;
4950
4967
  exports.DropdownMenuPortal = DropdownMenuPortal;
4968
+ exports.Editor = Editor;
4951
4969
  exports.FontFamilyTool = FontFamilyTool;
4952
4970
  exports.FontSizeTool = FontSizeTool;
4953
4971
  exports.HighlightBoxComponent = HighlightBoxComponent;
@@ -4992,7 +5010,6 @@ exports.codeFormatLoader = codeFormatLoader;
4992
5010
  exports.codeFormatter = codeFormatter;
4993
5011
  exports.colorFormatLoader = colorFormatLoader;
4994
5012
  exports.colorFormatter = colorFormatter;
4995
- exports.createXNote = createXNote;
4996
5013
  exports.deltaToBlock = deltaToBlock;
4997
5014
  exports.fontFamilyFormatLoader = fontFamilyFormatLoader;
4998
5015
  exports.fontFamilyFormatter = fontFamilyFormatter;