@textbus/platform-browser 3.0.0-alpha.25 → 3.0.0-alpha.26

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,3 +1,12 @@
1
+ /**
2
+ * 选区焦点可视位置
3
+ */
4
+ export interface Rect {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ }
1
10
  export interface UIElementParams {
2
11
  classes?: string[];
3
12
  attrs?: {
@@ -14,3 +23,4 @@ export interface UIElementParams {
14
23
  }
15
24
  export declare function createElement(tagName: string, options?: UIElementParams): HTMLElement;
16
25
  export declare function createTextNode(content: string): Text;
26
+ export declare function getLayoutRectByRange(range: Range): Rect;
@@ -1,6 +1,7 @@
1
1
  import { Injector } from '@tanbo/di';
2
2
  import { Selection, SelectionPaths, AbstractSelection, Scheduler } from '@textbus/core';
3
- import { SelectionBridge, Rect } from '../core/selection-bridge';
3
+ import { SelectionBridge } from '../core/selection-bridge';
4
+ import { Rect } from '../_utils/uikit';
4
5
  export interface RemoteSelection {
5
6
  id: string;
6
7
  color: string;
@@ -1,6 +1,6 @@
1
- export * from './caret';
2
1
  export * from './dom-renderer';
3
2
  export * from './injection-tokens';
4
- export * from './input';
3
+ export * from './magic-input';
4
+ export * from './native-input';
5
5
  export * from './selection-bridge';
6
6
  export * from './types';
@@ -40,6 +40,7 @@ export declare class DomRenderer implements NativeRenderer {
40
40
  addClass(target: NativeNode, name: string): void;
41
41
  removeClass(target: NativeNode, name: string): void;
42
42
  setStyle(target: NativeNode, key: string, value: any): void;
43
+ syncTextContent(target: NativeNode, content: string): void;
43
44
  removeStyle(target: NativeNode, key: string): void;
44
45
  setAttribute(target: NativeNode, key: string, value: string): void;
45
46
  removeAttribute(target: NativeNode, key: string): void;
@@ -0,0 +1,71 @@
1
+ import { Observable } from '@tanbo/stream';
2
+ import { Injector } from '@tanbo/di';
3
+ import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
4
+ import { Parser } from '../dom-support/parser';
5
+ import { Caret, CaretPosition, Input, Scroller } from './types';
6
+ interface CaretStyle {
7
+ height: string;
8
+ lineHeight: string;
9
+ fontSize: string;
10
+ }
11
+ declare class ExperimentalCaret implements Caret {
12
+ private scheduler;
13
+ private editorMask;
14
+ onPositionChange: Observable<CaretPosition | null>;
15
+ onStyleChange: Observable<CaretStyle>;
16
+ elementRef: HTMLElement;
17
+ get rect(): DOMRect;
18
+ private timer;
19
+ private caret;
20
+ private oldPosition;
21
+ private set display(value);
22
+ private get display();
23
+ private _display;
24
+ private flashing;
25
+ private subs;
26
+ private positionChangeEvent;
27
+ private styleChangeEvent;
28
+ private oldRange;
29
+ constructor(scheduler: Scheduler, editorMask: HTMLElement);
30
+ show(range: Range, restart: boolean): void;
31
+ hide(): void;
32
+ destroy(): void;
33
+ correctScrollTop(scroller: Scroller): void;
34
+ private updateCursorPosition;
35
+ }
36
+ /**
37
+ * Textbus PC 端输入实现
38
+ */
39
+ export declare class MagicInput extends Input {
40
+ private parser;
41
+ private keyboard;
42
+ private commander;
43
+ private selection;
44
+ private controller;
45
+ private scheduler;
46
+ private injector;
47
+ composition: boolean;
48
+ onReady: Promise<void>;
49
+ caret: ExperimentalCaret;
50
+ private container;
51
+ private subscription;
52
+ private doc;
53
+ private textarea;
54
+ private isFocus;
55
+ private nativeFocus;
56
+ private isSafari;
57
+ private isMac;
58
+ private isWindows;
59
+ private isSougouPinYin;
60
+ constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, injector: Injector);
61
+ focus(range: Range, restart: boolean): void;
62
+ blur(): void;
63
+ destroy(): void;
64
+ private init;
65
+ private handleDefaultActions;
66
+ private handlePaste;
67
+ private handleShortcut;
68
+ private handleInput;
69
+ private createEditableFrame;
70
+ }
71
+ export {};
@@ -0,0 +1,51 @@
1
+ import { Injector } from '@tanbo/di';
2
+ import { Subject } from '@tanbo/stream';
3
+ import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
4
+ import { Caret, CaretPosition, Input, Scroller } from './types';
5
+ import { Parser } from '../dom-support/parser';
6
+ declare class NativeCaret implements Caret {
7
+ private scheduler;
8
+ onPositionChange: Subject<CaretPosition | null>;
9
+ set nativeRange(range: Range | null);
10
+ get nativeRange(): Range | null;
11
+ get rect(): DOMRect | {
12
+ left: number;
13
+ top: number;
14
+ width: number;
15
+ height: number;
16
+ };
17
+ private oldPosition;
18
+ private _nativeRange;
19
+ private subs;
20
+ constructor(scheduler: Scheduler);
21
+ correctScrollTop(scroller: Scroller): void;
22
+ destroy(): void;
23
+ }
24
+ export declare class NativeInput extends Input {
25
+ private injector;
26
+ private parser;
27
+ private scheduler;
28
+ private selection;
29
+ private keyboard;
30
+ private commander;
31
+ private controller;
32
+ caret: NativeCaret;
33
+ composition: boolean;
34
+ onReady: Promise<void>;
35
+ private documentView;
36
+ private nativeSelection;
37
+ private subscription;
38
+ private nativeRange;
39
+ private isSafari;
40
+ private isMac;
41
+ private isSougouPinYin;
42
+ constructor(injector: Injector, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard, commander: Commander, controller: Controller);
43
+ focus(nativeRange: Range): void;
44
+ blur(): void;
45
+ destroy(): void;
46
+ private handleDefaultActions;
47
+ private handlePaste;
48
+ private handleShortcut;
49
+ private handleInput;
50
+ }
51
+ export {};
@@ -1,23 +1,14 @@
1
1
  import { Observable } from '@tanbo/stream';
2
2
  import { Injector } from '@tanbo/di';
3
3
  import { NativeSelectionBridge, NativeSelectionConnector, Renderer, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection } from '@textbus/core';
4
- import { Caret } from './caret';
5
- import { Input } from './input';
6
- /**
7
- * 选区焦点可视位置
8
- */
9
- export interface Rect {
10
- left: number;
11
- top: number;
12
- width: number;
13
- height: number;
14
- }
4
+ import { Rect } from '../_utils/uikit';
5
+ import { Input, ViewOptions } from './types';
15
6
  /**
16
7
  * Textbus PC 端选区桥接实现
17
8
  */
18
9
  export declare class SelectionBridge implements NativeSelectionBridge {
10
+ private config;
19
11
  private injector;
20
- caret: Caret;
21
12
  private controller;
22
13
  private selection;
23
14
  private rootComponentRef;
@@ -36,7 +27,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
36
27
  private maskContainer;
37
28
  private cacheCaretPositionTimer;
38
29
  private oldCaretPosition;
39
- constructor(injector: Injector, caret: Caret, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, renderer: Renderer);
30
+ constructor(config: ViewOptions, injector: Injector, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, renderer: Renderer);
40
31
  connect(connector: NativeSelectionConnector): void;
41
32
  disConnect(): void;
42
33
  getRect(location: SelectionPosition): Rect | null;
@@ -1,5 +1,7 @@
1
1
  import { ComponentLiteral, Module, TextbusConfig } from '@textbus/core';
2
+ import { Observable } from '@tanbo/stream';
2
3
  import { FormatLoader, ComponentLoader, AttributeLoader } from '../dom-support/parser';
4
+ import { Rect } from '../_utils/uikit';
3
5
  export interface ViewModule extends Module {
4
6
  componentLoaders?: ComponentLoader[];
5
7
  formatLoaders?: FormatLoader<any>[];
@@ -26,4 +28,33 @@ export interface ViewOptions extends TextbusConfig {
26
28
  styleSheets?: string[];
27
29
  /** 配置文档编辑状态下用到的样式 */
28
30
  editingStyleSheets?: string[];
31
+ /** 使用 contentEditable 作为编辑器控制可编辑范围 */
32
+ useContentEditable?: boolean;
33
+ }
34
+ export interface CaretLimit {
35
+ top: number;
36
+ bottom: number;
37
+ }
38
+ export interface Scroller {
39
+ onScroll: Observable<any>;
40
+ getLimit(): CaretLimit;
41
+ setOffset(offsetScrollTop: number): void;
42
+ }
43
+ export interface CaretPosition {
44
+ left: number;
45
+ top: number;
46
+ height: number;
47
+ }
48
+ export interface Caret {
49
+ onPositionChange: Observable<CaretPosition | null>;
50
+ readonly rect: Rect;
51
+ correctScrollTop(scroller: Scroller): void;
52
+ }
53
+ export declare abstract class Input {
54
+ abstract composition: boolean;
55
+ abstract onReady: Promise<void>;
56
+ abstract caret: Caret;
57
+ abstract focus(nativeRange: Range, reFlash: boolean): void;
58
+ abstract blur(): void;
59
+ abstract destroy(): void;
29
60
  }