@textbus/platform-browser 4.0.0-alpha.6 → 4.0.0-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.
@@ -1,7 +1,7 @@
1
1
  import 'reflect-metadata';
2
- import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge } from '@textbus/core';
3
- import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
2
+ import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge, FocusManager } from '@textbus/core';
4
3
  import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
4
+ import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
5
5
 
6
6
  function createElement(tagName, options = {}) {
7
7
  const el = document.createElement(tagName);
@@ -2331,11 +2331,29 @@ class BrowserModule {
2331
2331
  }, {
2332
2332
  provide: DomAdapter,
2333
2333
  useValue: config.adapter
2334
+ }, {
2335
+ provide: FocusManager,
2336
+ useFactory: (input) => {
2337
+ const focusEvent = new Subject();
2338
+ const blurEvent = new Subject();
2339
+ input.caret.onPositionChange.pipe(map(p => !!p), distinctUntilChanged()).subscribe(b => {
2340
+ if (b) {
2341
+ focusEvent.next();
2342
+ }
2343
+ else {
2344
+ blurEvent.next();
2345
+ }
2346
+ });
2347
+ return {
2348
+ onFocus: focusEvent,
2349
+ onBlur: blurEvent
2350
+ };
2351
+ },
2352
+ deps: [Input]
2334
2353
  },
2335
2354
  Parser,
2336
2355
  SelectionBridge,
2337
- CollaborateCursor
2338
- ];
2356
+ CollaborateCursor];
2339
2357
  this.workbench = wrapper;
2340
2358
  this.host.append(wrapper);
2341
2359
  }
package/bundles/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  require('reflect-metadata');
4
4
  var core$1 = require('@textbus/core');
5
- var core = require('@viewfly/core');
6
5
  var stream = require('@tanbo/stream');
6
+ var core = require('@viewfly/core');
7
7
 
8
8
  function createElement(tagName, options = {}) {
9
9
  const el = document.createElement(tagName);
@@ -2333,11 +2333,29 @@ class BrowserModule {
2333
2333
  }, {
2334
2334
  provide: DomAdapter,
2335
2335
  useValue: config.adapter
2336
+ }, {
2337
+ provide: core$1.FocusManager,
2338
+ useFactory: (input) => {
2339
+ const focusEvent = new stream.Subject();
2340
+ const blurEvent = new stream.Subject();
2341
+ input.caret.onPositionChange.pipe(stream.map(p => !!p), stream.distinctUntilChanged()).subscribe(b => {
2342
+ if (b) {
2343
+ focusEvent.next();
2344
+ }
2345
+ else {
2346
+ blurEvent.next();
2347
+ }
2348
+ });
2349
+ return {
2350
+ onFocus: focusEvent,
2351
+ onBlur: blurEvent
2352
+ };
2353
+ },
2354
+ deps: [Input]
2336
2355
  },
2337
2356
  exports.Parser,
2338
2357
  exports.SelectionBridge,
2339
- exports.CollaborateCursor
2340
- ];
2358
+ exports.CollaborateCursor];
2341
2359
  this.workbench = wrapper;
2342
2360
  this.host.append(wrapper);
2343
2361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.0",
29
- "@textbus/core": "^4.0.0-alpha.6",
29
+ "@textbus/core": "^4.0.0-alpha.7",
30
30
  "@viewfly/core": "^0.2.4",
31
31
  "reflect-metadata": "^0.1.13"
32
32
  },
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "47394e77de252fdfd9193e1620177f944976c1a9"
51
+ "gitHead": "b2f485e1177b20e88d302933760e741118ff8765"
52
52
  }