-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(embed): add method & event
edit
- Loading branch information
Showing
10 changed files
with
206 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ When instantiating `Flat.Embed`, you can pass options in the second parameter. I | |
* [`setAutoZoom`](#setautozoomboolean-promiseboolean-error): Enable or disable the auto-zoom mode | ||
* [Editor Methods](#editor-methods) | ||
* [`setEditorConfig`](#seteditorconfigconfig-object-promiseobject-error): Set the config of the editor | ||
* [`edit`](#editoperations-object-promisevoid-error): Make a modification to the document | ||
* [Events API](#events-api) | ||
* [`scoreLoaded`](#event-scoreLoaded): A new score has been loaded | ||
* [`cursorPosition`](#event-cursorposition): The cursor position changed | ||
|
@@ -108,6 +109,7 @@ When instantiating `Flat.Embed`, you can pass options in the second parameter. I | |
* [`pause`](#event-pause): The score playback paused | ||
* [`stop`](#event-stop): The score playback stopped | ||
* [`playbackPosition`](#event-playbackposition): The playback slider position changed | ||
* [`edit`](#event-edit): An edition has been made to the document | ||
|
||
## Viewer Methods | ||
|
||
|
@@ -382,9 +384,20 @@ embed.setAutoZoom(false).then(function (state) { | |
|
||
## Editor Methods | ||
|
||
You can enable the editor mode by setting the `mode` to `edit` when creating the embed: | ||
|
||
```js | ||
var embed = new Flat.Embed(container, { | ||
embedParams: { | ||
appId: '<your-app-id>', | ||
modeL 'edit' | ||
} | ||
}); | ||
``` | ||
|
||
### `setEditorConfig(config: object): Promise<object, Error>` | ||
|
||
Set a new config for the editor (e.g. the different tools available in the embed). | ||
Set a new config for the editor (e.g. the different tools available in the embed). This one will be used at the next loading score. | ||
|
||
```js | ||
// For example: hide the Articulation mode, and only display the durations tools in the Note mode | ||
|
@@ -399,6 +412,20 @@ embed.setEditorConfig({ | |
}); | ||
``` | ||
|
||
### `edit(operations: object): Promise<void, Error>` | ||
|
||
Process some edit operations using one of our internal editing method. Feel free to [contact our developers support](mailto:[email protected]) to get more information about the operations available. | ||
|
||
```js | ||
embed.edit([ | ||
{ name: 'action.SetTitle', opts: { title: 'I <3 Flat'} } | ||
]).then(function () { | ||
// The actions have been executed | ||
}).catch(function (error) { | ||
// Error while executing the actions | ||
}); | ||
``` | ||
|
||
## Events API | ||
|
||
Events are broadcasted following actions made by the end user or you with the JavaScript API. You can subscribe to an event using the method [`on`](#onevent-string-callback-function-void), and unsubscribe using [`off`](#onevent-string-callback-function-void). When an event includes some data, this data will be available in the first parameter of the listener callback. | ||
|
@@ -477,3 +504,25 @@ This event is triggered when the playback slider moves. It is usually triggered | |
"timePerMeasure": 2 | ||
} | ||
``` | ||
|
||
### Event: `edit` | ||
|
||
This event is triggered when one or multiple modifications ave been made to the document. This one will contain a list of operations made: | ||
|
||
```json | ||
[ | ||
{ | ||
"name": "action.SetTempo", | ||
"opts": { | ||
"startMeasureIdx": 0, | ||
"stopMeasureIdx": 1, | ||
"tempo": { | ||
"bpm": 142, | ||
"qpm": 142, | ||
"durationType": 3, | ||
"nbDots": 0 | ||
} | ||
} | ||
} | ||
] | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "flat-embed", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Interact and get events from Flat's Sheet Music Embed", | ||
"license": "Apache-2.0", | ||
"author": "Flat Team <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters