-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/pie 10.1.0 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edeustace
wants to merge
2
commits into
develop
Choose a base branch
from
feature/pie-10.1.0
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# PIE Authoring | ||
|
||
> Status: Draft | ||
|
||
Authoring depends on the `configure` components of a pie. These are optional packages that a pie developer can add to a pie definition. See [Configur](/docs/developing/configure) for more information. | ||
|
||
> The PIE cli `pie info` command will give a preview of the configure element if run from the foot of a pie item definition. | ||
|
||
## Handling Image Uploads | ||
|
||
Configure elements dispatch an event `'insert.image'`. See the [uploading](uploader.md) for more information. | ||
|
||
|
This file contains hidden or 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,96 +1,36 @@ | ||
# File Uploader | ||
# Image Upload | ||
|
||
> Status: Draft | ||
|
||
The File Uploader is provided to Configuration Elements to support uploading of assets that may be needed in a question. | ||
The details of delivering the file to a storage system are external to the Configuration Element. The page | ||
# Insert Image | ||
|
||
> See [pie-configure-events](https://github.com/pieelements/pie-elements) for information on the events dispatched. | ||
|
||
## How can I use it? | ||
|
||
An `uploader` property is set on the Config Panel Element by the page that contains the Element: | ||
Configure elements dispatch a `'insert.image'` event. The `event.detail` is a handler object with the following api: | ||
|
||
### `cancel()` | ||
|
||
To allow files to be selected and drag-dropped, you need to assign a drop target or a DOM item to be clicked for browsing for files: | ||
Cancels the insert image process. | ||
|
||
uploader.assignBrowse(document.getElementById('browseButton')); | ||
uploader.assignDrop(document.getElementById('dropTarget')); | ||
### `done(err?: Error, src:string)` | ||
|
||
After this, interaction with `uploader` is done by listening to events: | ||
Completes the insert image process, if `err` is present must be an `Error` with information on why the insertion failed. If `src` is present, it will be used as the href for a new `<img>` element. | ||
|
||
uploader.on('fileAdded', function(file, event){ | ||
... | ||
}); | ||
uploader.on('fileSuccess', function(file, message){ | ||
... | ||
}); | ||
uploader.on('fileError', function(file, message){ | ||
... | ||
}); | ||
### `fileChosen(file:File)` | ||
|
||
Notifies the handler that the user has chosen a file. | ||
|
||
### `progress(percent:number, bytes: number, total:number)` | ||
|
||
## `uploader` API | ||
Notifies the handler that progress has been made on uploading the image. | ||
|
||
|
||
#### Properties | ||
# Delete Image | ||
|
||
* `.files` An array of `UploadFile` file objects added by the user (see full docs for this object type below). | ||
Configure elements dispatch a '`delete.image`' event. The `event.detail` will contain: | ||
|
||
#### Methods | ||
* src - the src of the image | ||
* done - a function with the following type: `(err?: Error) => void`. | ||
|
||
* `.assignBrowse(domNodes, isDirectory)` Assign a browse action to one or more DOM nodes. Pass in `true` to allow directories to be selected (Chrome only). | ||
* `.assignDrop(domNodes)` Assign one or more DOM nodes as a drop target. | ||
* `.on(event, callback)` Listen for event from `uploader` (see below) | ||
* `.upload()` Start or resume uploading. | ||
* `.pause()` Pause uploading. | ||
* `.cancel()` Cancel upload of all `UploadFile` objects and remove them from the list. | ||
* `.progress()` Returns a float between 0 and 1 indicating the current upload progress of all files. | ||
* `.isUploading()` Returns a boolean indicating whether or not the instance is currently uploading anything. | ||
* `.addFile(file)` Add a HTML5 File object to the list of files. | ||
* `.removeFile(file)` Cancel upload of a specific `UploadFile` object on the list from the list. | ||
* `.getFromUniqueIdentifier(uniqueIdentifier)` Look up a `UploadFile` object by its unique identifier. | ||
* `.getSize()` Returns the total size of the upload in bytes. | ||
|
||
#### Events | ||
|
||
* `.fileSuccess(file, message)` A specific file was completed. `message` is the response body from the server. | ||
* `.fileProgress(file)` Uploading progressed for a specific file. | ||
* `.fileAdded(file, event)` A new file was added. Optionally, you can use the browser `event` object from when the file was added. | ||
* `.filesAdded(arrayAdded, arraySkipped)` New files were added (and maybe some have been skipped). | ||
* `.fileRetry(file)` Something went wrong during upload of a specific file, uploading is being retried. | ||
* `.fileError(file, message)` An error occurred during upload of a specific file. | ||
* `.uploadStart()` Upload has been started on the Resumable object. | ||
* `.complete()` Uploading completed. | ||
* `.progress()` Uploading progress. | ||
* `.error(message, file)` An error, including fileError, occurred. | ||
* `.pause()` Uploading was paused. | ||
* `.beforeCancel()` Triggers before the items are cancelled allowing to do any processing on uploading files. | ||
* `.cancel()` Uploading was canceled. | ||
* `.preparationStart(file)` Started preparing file for upload | ||
* `.preparationProgress(file,ratio)` Show progress in file preparation | ||
* `.preparationComplete(file)` File is ready for upload | ||
* `.catchAll(event, ...)` Listen to all the events listed above with the same callback function. | ||
|
||
### `UploadFile` API | ||
|
||
#### Properties | ||
|
||
* `.uploaderObj` A back-reference to the parent `uploader` object. | ||
* `.file` The correlating HTML5 `File` object. | ||
* `.fileName` The name of the file. | ||
* `.relativePath` The relative path to the file (defaults to file name if relative path doesn't exist) | ||
* `.size` Size in bytes of the file. | ||
* `.uniqueIdentifier` A unique identifier assigned to this file object. This value is included in uploads to the server for reference, but can also be used in CSS classes etc when building your upload UI. | ||
|
||
|
||
#### Methods | ||
|
||
* `.progress(relative)` Returns a float between 0 and 1 indicating the current upload progress of the file. If `relative` is `true`, the value is returned relative to all files in the `uploader` instance. | ||
* `.abort()` Abort uploading the file. | ||
* `.cancel()` Abort uploading the file and delete it from the list of files to upload. | ||
* `.retry()` Retry uploading the file. | ||
* `.bootstrap()` Rebuild the state of a `UploadFile` object, including reassigning chunks and XMLHttpRequest instances. | ||
* `.isUploading()` Returns a boolean indicating whether file chunks is uploading. | ||
* `.isComplete()` Returns a boolean indicating whether the file has completed uploading and received a server response. | ||
|
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Configure | ||
|
||
The configure package is used to render a configuration ui, that allows a user to update a data model for use with a pie `controller` and `element`. | ||
|
||
The configure package should export a custom element so it can be used as follows: | ||
|
||
```javascript | ||
import MyElConfigure from 'my-el-configure'; | ||
customElements.defined('my-el-configure', MyElConfigure); | ||
``` | ||
|
||
> The default export from the configure package should not define a custom element, this will be handled by pie. | ||
|
||
## Api | ||
|
||
### `set model(m:Object)` | ||
|
||
This sets the model on the element, which in turn should render a UI for the given model. | ||
|
||
### `Event: 'model.updated'` | ||
|
||
This event should be dispatched from the element if the `model` has been updated by the user. | ||
|
||
### `Event: 'insert.image'` | ||
|
||
This event should be dispatched if the user wishes to insert an image. See [Image Upload](/docs/authoring/uploader) for more information. | ||
|
||
> You can used [pie-configure-events](http://github.com/pieelements/pie-configure-events) for the 2 events above. |
This file contains hidden or 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
9 changes: 8 additions & 1 deletion
9
content/docs/developing/custom-element.md → content/docs/developing/element.md
This file contains hidden or 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
14 changes: 12 additions & 2 deletions
14
content/docs/developing/summary.md → content/docs/developing/introduction.md
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about file uploads? Like a video file or audio file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have it implemented right now, can we add it once it's implemented? maybe put in a coming soon? It'll be pretty similar to image upload.