@textbus/xnote 0.0.1-alpha.33 → 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(() => {
@@ -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);
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(() => {
@@ -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);
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.0.1-alpha.33",
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.62",
31
- "@textbus/collaborate": "^4.0.0-alpha.61",
32
- "@textbus/core": "^4.0.0-alpha.61",
33
- "@textbus/platform-browser": "^4.0.0-alpha.62",
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
  },