0.3.0 • Published 3 years ago

ngx-stackblitz v0.3.0

Weekly downloads
47
License
-
Repository
github
Last release
3 years ago

NgxStackblitz

Embed StackBlitz editor. See https://stackblitz.com/docs for more details.

npm install @stackblitz/sdk ngx-stackblitz

Create New Project

files = {
 'index.html': '<h1>My Test Page</h1>',
 'index.js': 'console.log("my test")'
}
<ngx-stackblitz-editor 
    [files]="files" 
    title="My test project"
    description="Just a test"
    template="javascript"
    (changed)="saveTree($event)"></ngx-stackblitz-editor>

Editor API

NameDescription
@Input() files: {[path: string]: string};List of files to add to the project
@Input() title: string;Project title
@Input() description: string;Project description
@Input() template: 'angular-cli' / 'create-react-app' / 'typescript' / 'javascript';Type of project to create
@Input() tags?: string[];Project tags
@Input() dependencies?: {[name: string]: string};NPM dependencies
@Input() settings?: any;Stackblitz Settings
@Input() openFile: string;Path to file that should open initially
@Input() view: string;(preview / editor) editor view
@Input() height: string;Editor height, defaults to 100%
@Input() width: string;Editor width, defaults to 100%
@Input() hideExplorer: boolean;Hide the file explorer, defaults to false
@Input() hideNavigation: boolean;Hide the editor nav, defaults to false
@Input() fileReadInterval: number;Interval (milliseconds) to poll editor for changes, defaults to every second
@Output() changed: EventEmitter<EditorChangeEvent>emitted every time the tree changes
@Output() loaded: EventEmitter<EditorFile[]>emitted when the tree is loaded
@Output() created: EventEmitter<EditorFile>emitted when a file is created
@Output() updated: EventEmitter<EditorFile>emitted when a file is updated
@Output() deleted: EventEmitter<EditorFile>emitted when a file is deleted

REQUIRED FILES FOR TEMPLATES

TemplateFiles
angular-cliRequires index.html and main.ts to be present
create-react-appRequires index.html and index.js to be present
typescriptRequires index.html and index.ts to be present
javascriptRequires index.html and index.js to be present

Embed GithubProject

<ngx-stackblitz-editor 
    repo="dig-platform/plugin-template" 
    (changed)="saveTree($event)"></ngx-stackblitz-editor>

Editor API

NameDescription
@Input() repo: string;github repo path ie: dig-hub/my-plugin
@Input() openFile: string;Path to file that should open initially
@Input() view: string;(preview / editor) editor view
@Input() height: string;Editor height, defaults to 100%
@Input() width: string;Editor width, defaults to 100%
@Input() hideExplorer: boolean;Hide the file explorer, defaults to false
@Input() hideNavigation: boolean;Hide the editor nav, defaults to false
@Input() fileReadInterval: number;Interval (milliseconds) to poll editor for changes, defaults to every second
@Output() changed: EventEmitter<EditorChangeEvent>emitted every time the tree changes
@Output() loaded: EventEmitter<EditorFile[]>emitted when the tree is loaded
@Output() created: EventEmitter<EditorFile>emitted when a file is created
@Output() updated: EventEmitter<EditorFile>emitted when a file is updated
@Output() deleted: EventEmitter<EditorFile>emitted when a file is deleted

Embed Existing Project

<ngx-stackblitz-editor 
    projectID="my-project" 
    (changed)="saveTree($event)"></ngx-stackblitz-editor>

Open existing project

NameDescription
@Input() projectID: string;Stackblitz project ID
@Input() openFile: string;Path to file that should open initially
@Input() view: string;(preview / editor) editor view
@Input() height: string;Editor height, defaults to 100%
@Input() width: string;Editor width, defaults to 100%
@Input() hideExplorer: boolean;Hide the file explorer, defaults to false
@Input() hideNavigation: boolean;Hide the editor nav, defaults to false
@Input() fileReadInterval: number;Interval (milliseconds) to poll editor for changes, defaults to every second
@Output() changed: EventEmitter<EditorChangeEvent>emitted every time the tree changes
@Output() loaded: EventEmitter<EditorFile[]>emitted when the tree is loaded
@Output() created: EventEmitter<EditorFile>emitted when a file is created
@Output() updated: EventEmitter<EditorFile>emitted when a file is updated
@Output() deleted: EventEmitter<EditorFile>emitted when a file is deleted

Interfaces

export interface EditorFile {
  path: string;
  content: string;
  status?: string;
}
export interface EditorChangeEvent {
  tree: EditorFile[];
  created?: EditorFile[];
  updated?: EditorFile[];
  deleted?: EditorFile[];
}
0.3.0

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago