@textbus/xnote 0.0.1-alpha.32 → 0.0.1-alpha.34

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.
@@ -1,11 +1,11 @@
1
- import { Props, ViewNode } from '@viewfly/core';
1
+ import { Props, JSXNode } from '@viewfly/core';
2
2
  export interface MenuItemProps extends Props {
3
3
  disabled?: boolean;
4
4
  checked?: boolean;
5
- icon?: ViewNode;
5
+ icon?: JSXNode;
6
6
  value?: any;
7
7
  arrow?: boolean;
8
- desc?: ViewNode;
8
+ desc?: JSXNode;
9
9
  onClick?(value: any): void;
10
10
  }
11
11
  export declare function MenuItem(props: MenuItemProps): () => any;
@@ -2635,6 +2635,8 @@ function useBlockTransform() {
2635
2635
  lineNumber: true,
2636
2636
  autoBreak: true,
2637
2637
  slots: slots.map(slot => {
2638
+ slot.cleanFormats();
2639
+ slot.cleanAttributes();
2638
2640
  return {
2639
2641
  slot,
2640
2642
  emphasize: false
@@ -3463,7 +3465,6 @@ function LinkTool(props) {
3463
3465
  });
3464
3466
  }
3465
3467
  isShow.set(false);
3466
- editorService.hideInlineToolbar = false;
3467
3468
  }
3468
3469
  let isClickFromSelf = false;
3469
3470
  const sub = fromEvent(document, 'click').subscribe(() => {
@@ -3608,7 +3609,7 @@ function VideoView(props) {
3608
3609
  const output = useOutput();
3609
3610
  return () => {
3610
3611
  if (readonly() || output()) {
3611
- return (jsx("div", { class: "xnote-video", "data-component": name, children: jsx("video", { ref: videoRef, src: state.src, style: {
3612
+ return (jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsx("video", { ref: videoRef, src: state.src, style: {
3612
3613
  width: state.width,
3613
3614
  height: state.height
3614
3615
  } }) }));
@@ -3888,7 +3889,7 @@ function InsertTool(props) {
3888
3889
  break;
3889
3890
  case 'image':
3890
3891
  if (fileUploader) {
3891
- Promise.resolve(fileUploader.uploadFile('image')).then(url => {
3892
+ Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
3892
3893
  const img = new ImageComponent(textbus, {
3893
3894
  src: url
3894
3895
  });
@@ -3898,7 +3899,7 @@ function InsertTool(props) {
3898
3899
  break;
3899
3900
  case 'video':
3900
3901
  if (fileUploader) {
3901
- Promise.resolve(fileUploader.uploadFile('video')).then(url => {
3902
+ Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
3902
3903
  const img = new VideoComponent(textbus, {
3903
3904
  src: url
3904
3905
  });
@@ -4212,6 +4213,7 @@ function LinkJump() {
4212
4213
  onSelectionChange();
4213
4214
  });
4214
4215
  function cleanLink() {
4216
+ isShow.set(false);
4215
4217
  const commonAncestorSlot = selection.commonAncestorSlot;
4216
4218
  const index = selection.focusOffset;
4217
4219
  const ranges = commonAncestorSlot.getFormatRangesByFormatter(linkFormatter, 0, commonAncestorSlot.length);
@@ -4237,6 +4239,8 @@ const Toolbar = withAnnotation({
4237
4239
  }, function Toolbar() {
4238
4240
  const selection = inject(Selection);
4239
4241
  const viewDocument = inject(VIEW_CONTAINER);
4242
+ const rootComponentRef = inject(RootComponentRef);
4243
+ const adapter = inject(DomAdapter);
4240
4244
  const bridge = inject(SelectionBridge);
4241
4245
  const textbus = inject(Textbus);
4242
4246
  const editorService = inject(EditorService);
@@ -4258,7 +4262,7 @@ const Toolbar = withAnnotation({
4258
4262
  const toolbarRef = createRef();
4259
4263
  function getTop() {
4260
4264
  const docRect = viewDocument.getBoundingClientRect();
4261
- const toolbarRect = toolbarRef.current.getBoundingClientRect();
4265
+ const toolbarHeight = 36;
4262
4266
  // const documentHeight = document.documentElement.clientHeight
4263
4267
  const selectionFocusRect = bridge.getRect({
4264
4268
  slot: selection.focusSlot,
@@ -4267,12 +4271,11 @@ const Toolbar = withAnnotation({
4267
4271
  if (!selectionFocusRect) {
4268
4272
  return null;
4269
4273
  }
4270
- // console.log(selectionFocusRect.top, toolbarRect.height)
4271
4274
  const centerLeft = selectionFocusRect.left;
4272
- const toBottom = selectionFocusRect.top < toolbarRect.height + 10;
4275
+ const toBottom = selectionFocusRect.top < toolbarHeight + 10;
4273
4276
  const top = toBottom ?
4274
4277
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
4275
- selectionFocusRect.top - docRect.top - toolbarRect.height - 10;
4278
+ selectionFocusRect.top - docRect.top - toolbarHeight - 10;
4276
4279
  updateViewPosition(draft => {
4277
4280
  draft.transitionDuration = .15;
4278
4281
  draft.left = centerLeft - docRect.left;
@@ -4294,7 +4297,8 @@ const Toolbar = withAnnotation({
4294
4297
  sub.unsubscribe();
4295
4298
  });
4296
4299
  function bindMouseup() {
4297
- mouseupSubscription = fromEvent(viewDocument, 'mouseup').pipe(filter(ev => {
4300
+ const docElement = adapter.getNativeNodeByComponent(rootComponentRef.component);
4301
+ mouseupSubscription = fromEvent(docElement, 'mouseup').pipe(filter(ev => {
4298
4302
  return !ev.composedPath().includes(toolbarRef.current);
4299
4303
  }), delay(100), filter(() => {
4300
4304
  return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
@@ -5735,4 +5739,4 @@ class Editor extends Textbus {
5735
5739
  }
5736
5740
  }
5737
5741
 
5738
- export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CodeTool, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuPortal, DropdownService, Editor, EditorService, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Popup, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, StrikeThroughTool, TableComponent, TableComponentView, TodolistComponent, TodolistView, Toolbar, ToolbarItem, ToolbarPlugin, UnderlineTool, VideoComponent, VideoView, atComponentLoader, autoComplete, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, 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 };
5742
+ export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, 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, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Popup, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, StrikeThroughTool, TableComponent, TableComponentView, TodolistComponent, TodolistView, Toolbar, ToolbarItem, ToolbarPlugin, UnderlineTool, VideoComponent, VideoView, atComponentLoader, autoComplete, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, 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 };
package/bundles/index.js CHANGED
@@ -2637,6 +2637,8 @@ function useBlockTransform() {
2637
2637
  lineNumber: true,
2638
2638
  autoBreak: true,
2639
2639
  slots: slots.map(slot => {
2640
+ slot.cleanFormats();
2641
+ slot.cleanAttributes();
2640
2642
  return {
2641
2643
  slot,
2642
2644
  emphasize: false
@@ -3465,7 +3467,6 @@ function LinkTool(props) {
3465
3467
  });
3466
3468
  }
3467
3469
  isShow.set(false);
3468
- editorService.hideInlineToolbar = false;
3469
3470
  }
3470
3471
  let isClickFromSelf = false;
3471
3472
  const sub = core$1.fromEvent(document, 'click').subscribe(() => {
@@ -3610,7 +3611,7 @@ function VideoView(props) {
3610
3611
  const output = useOutput();
3611
3612
  return () => {
3612
3613
  if (readonly() || output()) {
3613
- return (jsxRuntime.jsx("div", { class: "xnote-video", "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
3614
+ return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
3614
3615
  width: state.width,
3615
3616
  height: state.height
3616
3617
  } }) }));
@@ -3890,7 +3891,7 @@ function InsertTool(props) {
3890
3891
  break;
3891
3892
  case 'image':
3892
3893
  if (fileUploader) {
3893
- Promise.resolve(fileUploader.uploadFile('image')).then(url => {
3894
+ Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
3894
3895
  const img = new ImageComponent(textbus, {
3895
3896
  src: url
3896
3897
  });
@@ -3900,7 +3901,7 @@ function InsertTool(props) {
3900
3901
  break;
3901
3902
  case 'video':
3902
3903
  if (fileUploader) {
3903
- Promise.resolve(fileUploader.uploadFile('video')).then(url => {
3904
+ Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
3904
3905
  const img = new VideoComponent(textbus, {
3905
3906
  src: url
3906
3907
  });
@@ -4214,6 +4215,7 @@ function LinkJump() {
4214
4215
  onSelectionChange();
4215
4216
  });
4216
4217
  function cleanLink() {
4218
+ isShow.set(false);
4217
4219
  const commonAncestorSlot = selection.commonAncestorSlot;
4218
4220
  const index = selection.focusOffset;
4219
4221
  const ranges = commonAncestorSlot.getFormatRangesByFormatter(linkFormatter, 0, commonAncestorSlot.length);
@@ -4239,6 +4241,8 @@ const Toolbar = core.withAnnotation({
4239
4241
  }, function Toolbar() {
4240
4242
  const selection = core.inject(core$1.Selection);
4241
4243
  const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
4244
+ const rootComponentRef = core.inject(core$1.RootComponentRef);
4245
+ const adapter = core.inject(platformBrowser.DomAdapter);
4242
4246
  const bridge = core.inject(platformBrowser.SelectionBridge);
4243
4247
  const textbus = core.inject(core$1.Textbus);
4244
4248
  const editorService = core.inject(exports.EditorService);
@@ -4260,7 +4264,7 @@ const Toolbar = core.withAnnotation({
4260
4264
  const toolbarRef = core.createRef();
4261
4265
  function getTop() {
4262
4266
  const docRect = viewDocument.getBoundingClientRect();
4263
- const toolbarRect = toolbarRef.current.getBoundingClientRect();
4267
+ const toolbarHeight = 36;
4264
4268
  // const documentHeight = document.documentElement.clientHeight
4265
4269
  const selectionFocusRect = bridge.getRect({
4266
4270
  slot: selection.focusSlot,
@@ -4269,12 +4273,11 @@ const Toolbar = core.withAnnotation({
4269
4273
  if (!selectionFocusRect) {
4270
4274
  return null;
4271
4275
  }
4272
- // console.log(selectionFocusRect.top, toolbarRect.height)
4273
4276
  const centerLeft = selectionFocusRect.left;
4274
- const toBottom = selectionFocusRect.top < toolbarRect.height + 10;
4277
+ const toBottom = selectionFocusRect.top < toolbarHeight + 10;
4275
4278
  const top = toBottom ?
4276
4279
  selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
4277
- selectionFocusRect.top - docRect.top - toolbarRect.height - 10;
4280
+ selectionFocusRect.top - docRect.top - toolbarHeight - 10;
4278
4281
  updateViewPosition(draft => {
4279
4282
  draft.transitionDuration = .15;
4280
4283
  draft.left = centerLeft - docRect.left;
@@ -4296,7 +4299,8 @@ const Toolbar = core.withAnnotation({
4296
4299
  sub.unsubscribe();
4297
4300
  });
4298
4301
  function bindMouseup() {
4299
- mouseupSubscription = core$1.fromEvent(viewDocument, 'mouseup').pipe(core$1.filter(ev => {
4302
+ const docElement = adapter.getNativeNodeByComponent(rootComponentRef.component);
4303
+ mouseupSubscription = core$1.fromEvent(docElement, 'mouseup').pipe(core$1.filter(ev => {
4300
4304
  return !ev.composedPath().includes(toolbarRef.current);
4301
4305
  }), core$1.delay(100), core$1.filter(() => {
4302
4306
  return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
@@ -5753,6 +5757,7 @@ exports.DragResize = DragResize;
5753
5757
  exports.Dropdown = Dropdown;
5754
5758
  exports.DropdownMenuPortal = DropdownMenuPortal;
5755
5759
  exports.Editor = Editor;
5760
+ exports.FileUploader = FileUploader;
5756
5761
  exports.FontFamilyTool = FontFamilyTool;
5757
5762
  exports.FontSizeTool = FontSizeTool;
5758
5763
  exports.HighlightBoxComponent = HighlightBoxComponent;
@@ -1,4 +1,4 @@
1
1
  export declare function LinkJump(): {
2
2
  $portalHost: HTMLElement;
3
- $render: () => import("@viewfly/core").JSXNode<string | JSXInternal.ComponentSetup<any>>;
3
+ $render: () => import("@viewfly/core").ViewFlyNode<string | import("@viewfly/core").ComponentSetup<any>>;
4
4
  };
@@ -2,4 +2,5 @@ export * from './components/_api';
2
2
  export * from './plugins/_api';
3
3
  export * from './services/_api';
4
4
  export * from './textbus/_api';
5
+ export * from './interfaces';
5
6
  export * from './editor';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.0.1-alpha.32",
3
+ "version": "0.0.1-alpha.34",
4
4
  "description": "A high-performance rich text editor that supports multiplayer online collaboration.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -27,14 +27,14 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@tanbo/color": "^0.1.1",
30
- "@textbus/adapter-viewfly": "^4.0.0-alpha.61",
31
- "@textbus/collaborate": "^4.0.0-alpha.61",
32
- "@textbus/core": "^4.0.0-alpha.61",
33
- "@textbus/platform-browser": "^4.0.0-alpha.61",
34
- "@viewfly/core": "^1.0.0-alpha.11",
35
- "@viewfly/hooks": "^1.0.0-alpha.11",
36
- "@viewfly/platform-browser": "^1.0.0-alpha.11",
37
- "@viewfly/scoped-css": "^1.0.0-alpha.11",
30
+ "@textbus/adapter-viewfly": "^4.0.0-alpha.64",
31
+ "@textbus/collaborate": "^4.0.0-alpha.64",
32
+ "@textbus/core": "^4.0.0-alpha.64",
33
+ "@textbus/platform-browser": "^4.0.0-alpha.64",
34
+ "@viewfly/core": "^1.0.0-alpha.16",
35
+ "@viewfly/hooks": "^1.0.0-alpha.16",
36
+ "@viewfly/platform-browser": "^1.0.0-alpha.16",
37
+ "@viewfly/scoped-css": "^1.0.0-alpha.16",
38
38
  "highlight.js": "^11.9.0",
39
39
  "katex": "^0.16.10"
40
40
  },