9.0.10076 • Published 4 years ago

@ibm-wch-sdk/edit-api v9.0.10076

Weekly downloads
17
License
MIT
Repository
-
Last release
4 years ago

ibm-wch-sdk-edit-api

Exposes framework independent APIs for ibm-wch-sdk-edit-ng and similar SDKs.

Changes

CHANGELOG

Details

Refer to the documentation.

Class documentation

Refer to the documentation.

Changelog

Current

Added

  • Expose ActivePageService as active-page module to the edit provider

6.0.69

Changed

  • Added compatibility layer for EventTargetLike
  • Improved readme

Added

  • Initial version

Edit API

The edit API defines interfaces for consumers and providers of inline edit functionality.

  • interfaces: list of interfaces a consumer of the inline edit API can use to interact with a provider of this functionality.
  • provider: list of interfaces a provider of the inline edit API has to satisfy
  • modules: modules that the provider can use as context from the consuming host.

@ibm-wch-sdk/edit-api

Index

External modules


Interfaces

This section describes the interfaces exposed by the module.

WchInlineEditService

The WchInlineEditService interface allows a client to interact with the inline edit implementation. The implementation of this interface makes sure to load the inline edit provider and to fulfill the interface contract with the provider.

A consumer of this interface calls the registerComponent message for each HTML element that is supposed to be edited. The result of this call is an Observable. The inline edit registration begins as soon as someone subscribes to this observable and ends as soon as this subscription ends. It is in the responsibility of the consumer to make sure that the HTML element exists for the duration of the subscription.

Provider

The edit provider is a piece of javascript code that implements inline edit functionality. It is dynamically loaded by the SPA (typically via the SDK). The provider needs to conform to the following pattern:

Initialization

The edit module implements the WchInlineEditProvider interface, i.e. it exposes a register function. This function will be invoked for each editable HTML element and allows the edit provider to attach the desired edit hooks to the elements. The method is provided with:

  • a reference to the actual HTML element
  • an accessor expression that identifies the element on a content item to be edited. This expression is relative to the current rendering context
  • a reactive stream of rendering contexts. Note that the rendering contexts can change during the lifetime of this registration. Also there is no guarantee that the element pointed to by the accessor actually exists on the context. If a provide subscribes to the sequence of rendering contexts, it needs to make sure to NOT throw an exception in the subscribe block under any circumstances

Result

The result of a registration is an event provider. The purpose of this provider is to communicate inline edit operations on the HTML element to the host, i.e. the host registers for events on that event provider and the edit provider is responsible to firing these events (if the event is supported).

The event provider can optionally implement the Disposable interface. If implemented the host will call its dispose method after registration, before the HTML element gets removed from the DOM (so it's the inverse operation to the registration call).

Notifications

The implementor of the WchInlineEditProvider can optionally also implement the EventTargetLike interface, i.e. be an event emitter. This allows the provider to communicate information to the SDK, e.g. about enabled or disabled inline edit mode.

Currently supported notifications are:

  • wchInlineEditStart to notify about entering inline edit mode
  • wchInlineEditEnd to notify about leaving inline edit mode

Modules

The inline-edit-provider can use the global require function to access functionality (modules) provided by the edit host. The result of the require call is a Promise that resolves to an API object. This section lists the available modules.

WCH_LOGGER_MODULE

The wch-logger module provides access the to logging APIs. Edit providers are encouraged to use this API instead of the console to issue logging statements (see LoggerService).

WCH_INFO_MODULE

The wch-info module exposes information about the entry point URLs and whether or not the system is in preview mode or in live mode (see UrlConfig).

WCH_CONFIG_MODULE

The wch-config module exposes information about configured URLs for the current tenant, e.g. the URL to the authoring host.

WCH_ACTIVE_PAGE_MODULE

The wch-active-page module exposes the ActivePage interface.

@ibm-wch-sdk/edit-api > "compat"

External module: "compat"

Index

Interfaces

Type aliases


Type aliases

EventTargetLike

Ƭ EventTargetLike: HasEventTargetAddRemove<T> | NodeStyleEventEmitter | JQueryStyleEventEmitter

Defined in compat.ts:39


NodeEventHandler

Ƭ NodeEventHandler: function

Defined in compat.ts:19

Type declaration

▸(...args: any[]): void

Parameters:

ParamType
Rest argsany[]

Returns: void


@ibm-wch-sdk/edit-api > "index"

External module: "index"

Index


@ibm-wch-sdk/edit-api > "interfaces/inline.edit.service"

External module: "interfaces/inline.edit.service"

Index

Interfaces

Type aliases


Type aliases

AccessorType

Ƭ AccessorType: string | null

Defined in interfaces/inline.edit.service.ts:8


@ibm-wch-sdk/edit-api > "modules/modules"

External module: "modules/modules"

Index

Variables


Variables

<Const> WCH_ACTIVE_PAGE_MODULE

● WCH_ACTIVE_PAGE_MODULE: "wch-active-page" = "wch-active-page"

Defined in modules/modules.ts:15

Token used to require the active page service see: PromiseLike


<Const> WCH_CONFIG_MODULE

● WCH_CONFIG_MODULE: "wch-config" = "wch-config"

Defined in modules/modules.ts:36

Token used to require the WchConfig service see: PromiseLike


<Const> WCH_HTTP_MODULE

● WCH_HTTP_MODULE: "wch-http" = "wch-http"

Defined in modules/modules.ts:8

Token used to access the http service see: PromiseLike


<Const> WCH_INFO_MODULE

● WCH_INFO_MODULE: "wch-info" = "wch-info"

Defined in modules/modules.ts:29

Token used to require the [[WchInfo]] service see: PromiseLike


<Const> WCH_LOGGER_MODULE

● WCH_LOGGER_MODULE: "wch-logger" = "wch-logger"

Defined in modules/modules.ts:22

Token used to require the [[LoggerService]] see: PromiseLike


@ibm-wch-sdk/edit-api > "modules/wch.config"

External module: "modules/wch.config"

Index

Interfaces


@ibm-wch-sdk/edit-api > "provider/disposable"

External module: "provider/disposable"

Index

Interfaces


@ibm-wch-sdk/edit-api > "provider/editable.event"

External module: "provider/editable.event"

Index

Interfaces


@ibm-wch-sdk/edit-api > "provider/inline.edit.event"

External module: "provider/inline.edit.event"

Index

Interfaces


@ibm-wch-sdk/edit-api > "provider/inline.edit.provider"

External module: "provider/inline.edit.provider"

Index

Interfaces

Type aliases


Type aliases

WchInlineEditRegistration

Ƭ WchInlineEditRegistration: function

Defined in provider/inline.edit.provider.ts:11

Type declaration

▸(nativeElement: any, accessor: AccessorType, onRenderingContext: Observable<RenderingContext>): WchInlineEditRegistrationResult

Parameters:

ParamType
nativeElementany
accessorAccessorType
onRenderingContextObservable<RenderingContext>

Returns: WchInlineEditRegistrationResult


WchInlineEditRegistrationResult

Ƭ WchInlineEditRegistrationResult: * EventTargetLike<any> | EventTargetLike<any> & Disposable

*

Defined in provider/inline.edit.provider.ts:9


@ibm-wch-sdk/edit-api

Index

External modules


@ibm-wch-sdk/edit-api > "compat" > HasEventTargetAddRemove

Interface: HasEventTargetAddRemove

Type parameters

E

Hierarchy

HasEventTargetAddRemove

Index

Methods


Methods

addEventListener

addEventListener(type: string, listener: function | null, options?: boolean | AddEventListenerOptions): void

Defined in compat.ts:27

Parameters:

ParamType
typestring
listenerfunction | null
Optional optionsboolean | AddEventListenerOptions

Returns: void


removeEventListener

removeEventListener(type: string, listener?: function | null, options?: EventListenerOptions | boolean): void

Defined in compat.ts:32

Parameters:

ParamType
typestring
Optional listenerfunction | null
Optional optionsEventListenerOptions | boolean

Returns: void


@ibm-wch-sdk/edit-api > "compat" > JQueryStyleEventEmitter

Interface: JQueryStyleEventEmitter

Hierarchy

JQueryStyleEventEmitter

Index

Properties


Properties

off

● off: function

Defined in compat.ts:23

Type declaration

▸(eventName: string, handler: Function): void

Parameters:

ParamType
eventNamestring
handlerFunction

Returns: void


on

● on: function

Defined in compat.ts:22

Type declaration

▸(eventName: string, handler: Function): void

Parameters:

ParamType
eventNamestring
handlerFunction

Returns: void


@ibm-wch-sdk/edit-api > "compat" > NodeStyleEventEmitter

Interface: NodeStyleEventEmitter

These definitons have basically been copied from

https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/fromEvent.ts

because they are not exported from rxjs. Apparently this is intended by the rxjs authors:

https://github.com/ReactiveX/rxjs/issues/3658

Hierarchy

NodeStyleEventEmitter

Index

Properties


Properties

addListener

● addListener: function

Defined in compat.ts:12

Type declaration

▸(eventName: string | symbol, handler: NodeEventHandler): this

Parameters:

ParamType
eventNamestring | symbol
handlerNodeEventHandler

Returns: this


removeListener

● removeListener: function

Defined in compat.ts:13

Type declaration

▸(eventName: string | symbol, handler: NodeEventHandler): this

Parameters:

ParamType
eventNamestring | symbol
handlerNodeEventHandler

Returns: this


@ibm-wch-sdk/edit-api > "interfaces/inline.edit.service" > WchInlineEditService

Interface: WchInlineEditService

Implementation of the edit service used by the wchEditable directive.

Hierarchy

WchInlineEditService

Index

Methods


Methods

fromEvent

fromEvent<T>(aName: string): Observable<T>

Defined in interfaces/inline.edit.service.ts:39

Attaches to an event issued by the edit library

Type parameters:

T

Parameters:

ParamTypeDescription
aNamestringname of the event

Returns: Observable<T>


registerComponent

registerComponent(nativeElement: any, accessor: AccessorType, onRenderingContext: Observable<RenderingContext>): Observable<EventTargetLike<any>>

Defined in interfaces/inline.edit.service.ts:27

Registers a particular DOM element as editable

Parameters:

ParamTypeDescription
nativeElementanythe DOM element to be edited
accessorAccessorTypestring identifying the member in the content item record to be edited. The value of 'null' means the the content item itself will be edited.
onRenderingContextObservable<RenderingContext>the rendering context associated with the edit operation. The same DOM element might represent multiple contexts over time

Returns: Observable<EventTargetLike<any>> the observable representing the registration result. The observable exposes an event producer that a client can attach to to receive edit events. The registration will only take place when subscribing to the observable and it will end when unsubscribing.


@ibm-wch-sdk/edit-api > "modules/wch.config" > WchConfig

Interface: WchConfig

Exposes server side configuration for the current tenant

Hierarchy

WchConfig

Index

Properties


Properties

apiUrl

● apiUrl: URL

Defined in modules/wch.config.ts:6

API URL for the non-preview host


authoringUIBaseUrl

● authoringUIBaseUrl: URL

Defined in modules/wch.config.ts:9

URL of the authoring host


deliveryUrl

● deliveryUrl: URL

Defined in modules/wch.config.ts:12

delivery URL for the non-preview host


previewApiUrl

● previewApiUrl: URL

Defined in modules/wch.config.ts:15

API URL for the preview host


previewDeliveryUrl

● previewDeliveryUrl: URL

Defined in modules/wch.config.ts:18

delivery URL for the preview host


@ibm-wch-sdk/edit-api > "provider/disposable" > Disposable

Interface: Disposable

Implemented by objects that expose a life cycle. Calling the dispose method signals the end of this life cycle.

Hierarchy

Disposable

Index

Properties


Properties

dispose

● dispose: function

Defined in provider/disposable.ts:7

Type declaration

▸(): void

Returns: void


@ibm-wch-sdk/edit-api > "provider/editable.event" > WchEditableEvent

Interface: WchEditableEvent

Event issued by the edit provider.

Hierarchy

WchEditableEvent

Index

Properties


Properties

data

● data: any

Defined in provider/editable.event.ts:13


target

● target: HTMLElement

Defined in provider/editable.event.ts:11


type

● type: string

Defined in provider/editable.event.ts:9


@ibm-wch-sdk/edit-api > "provider/inline.edit.provider" > WchInlineEditProvider

Interface: WchInlineEditProvider

Hierarchy

WchInlineEditProvider

Index

Properties


Properties

register

● register: WchInlineEditRegistration

Defined in provider/inline.edit.provider.ts:15


@ibm-wch-sdk/edit-api > "provider/inline.edit.event" > WchInlineEditEvent

Interface: WchInlineEditEvent

Event issued by the edit library

Hierarchy

WchInlineEditEvent

Index

Properties


Properties

data

● data: any

Defined in provider/inline.edit.event.ts:9


type

● type: string

Defined in provider/inline.edit.event.ts:7


9.0.10076

4 years ago

9.0.10067

4 years ago

9.0.10034

4 years ago

9.0.10040

4 years ago

9.0.495

4 years ago

9.0.493

4 years ago

9.0.462

4 years ago

9.0.407

4 years ago

9.0.384

4 years ago

9.0.361

4 years ago

9.0.360

4 years ago

9.0.271

4 years ago

9.0.251

4 years ago

9.0.242

4 years ago

9.0.209

4 years ago

9.0.216

4 years ago

6.0.524

5 years ago

7.2.608

5 years ago

7.2.591

5 years ago

7.2.435

5 years ago

7.2.407

5 years ago

7.2.358

5 years ago

7.2.291

5 years ago

7.2.290

5 years ago

6.0.498

5 years ago

6.0.496

5 years ago

6.0.477

5 years ago

7.0.165

5 years ago

7.0.163

5 years ago

7.0.151

5 years ago

6.0.455

6 years ago

7.0.25

6 years ago

7.0.22

6 years ago

7.0.16

6 years ago

7.0.14

6 years ago

6.0.401

6 years ago

6.0.383

6 years ago

6.0.264

6 years ago

6.0.293

6 years ago

6.0.287

6 years ago

6.0.238

6 years ago

6.0.232

6 years ago

6.0.185

6 years ago

6.0.162

6 years ago

6.0.159

6 years ago

6.0.157

6 years ago

6.0.155

6 years ago

6.0.154

6 years ago

6.0.152

6 years ago

6.0.149

6 years ago

6.0.126

6 years ago

6.0.120

6 years ago

6.0.119

6 years ago

6.0.118

6 years ago

6.0.112

6 years ago

6.0.108

6 years ago

6.0.107

6 years ago

6.0.75

6 years ago

6.0.66

6 years ago

6.0.54

6 years ago

6.0.42

6 years ago

6.0.41

6 years ago

6.0.17

6 years ago