Repository: wulfsolter/angular2-signaturepad
Branch: master
Commit: a016054b352f
Files: 24
Total size: 26.5 KB
Directory structure:
gitextract_blae03qp/
├── .editorconfig
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── angular.json
├── index.ts
├── package.json
├── projects/
│ └── angular2-signaturepad/
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src/
│ │ ├── lib/
│ │ │ ├── angular2-signaturepad.component.spec.ts
│ │ │ ├── angular2-signaturepad.component.ts
│ │ │ └── angular2-signaturepad.module.ts
│ │ ├── public-api.ts
│ │ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.lib.prod.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── signature-pad.ts
├── tsconfig.json
└── tslint.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false
================================================
FILE: .gitignore
================================================
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
================================================
FILE: .npmignore
================================================
# Node generated files
node_modules
npm-debug.log
# OS generated files
Thumbs.db
.DS_Store
# Ignored files
*.ts
!*.d.ts
# ngc generated files
ngfactory
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016 Wulf Sölter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# angular2-signaturepad
Angular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
# No Longer Maintained
<< THIS IS NO LONGER IN USE BY OWNER. PROBLEMS CAN AND DO EXIST. PRs ARE SUPER WELCOME, BUT I CAN NOT IDENTIFY WHAT YOUR ISSUES ARE, NOR WILL I CHANGE THINGS BECAUSE ANGULAR HAS CHANGED IN THE YEARS SINCE I WROTE THIS. I DO NOT USE THIS, I CAN'T HELP YOU WITH YOUR PROBLEMS. >>
## Install
`npm install angular2-signaturepad --save`
## Reference Implementation
* [Live Demo](http://lathonez.com/angular2-signaturepad-demo/)
* [Source](https://github.com/lathonez/angular2-signaturepad-demo)
## Usage example
API is identical to [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
Options are as per [szimek/signature_pad](https://www.npmjs.com/package/signature_pad) with the following additions:
* canvasWidth: width of the canvas (px)
* canvasHeight: height of the canvas (px)
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
```typescript
// import into app module
import { SignaturePadModule } from 'angular2-signaturepad';
...
@NgModule({
declarations: [ ],
imports: [ SignaturePadModule ],
providers: [ ],
bootstrap: [ AppComponent ]
})
// then import for use in a component
import { Component, ViewChild } from 'angular2/core';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
@Component({
template: '<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>'
})
export class SignaturePadPage{
@ViewChild(SignaturePad) signaturePad: SignaturePad;
signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
}
```
================================================
FILE: angular.json
================================================
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular2-signaturepad": {
"projectType": "library",
"root": "projects/angular2-signaturepad",
"sourceRoot": "projects/angular2-signaturepad/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "projects/angular2-signaturepad/tsconfig.lib.json",
"project": "projects/angular2-signaturepad/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/angular2-signaturepad/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/angular2-signaturepad/src/test.ts",
"tsConfig": "projects/angular2-signaturepad/tsconfig.spec.json",
"karmaConfig": "projects/angular2-signaturepad/karma.conf.js"
}
}
}
}
},
"defaultProject": "angular2-signaturepad"
}
================================================
FILE: index.ts
================================================
import { NgModule } from '@angular/core';
import { SignaturePad } from './signature-pad';
@NgModule({
imports: [ ],
declarations: [ SignaturePad ],
exports: [ SignaturePad ],
})
export class SignaturePadModule { }
================================================
FILE: package.json
================================================
{
"name": "angular2-signaturepad",
"version": "4.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"dependencies": {
"@angular/animations": "~13.0.2",
"@angular/common": "~13.0.2",
"@angular/compiler": "~13.0.2",
"@angular/core": "~13.0.2",
"@angular/forms": "~13.0.2",
"@angular/platform-browser": "~13.0.2",
"@angular/platform-browser-dynamic": "~13.0.2",
"@angular/router": "~13.0.2",
"rxjs": "~6.6.0",
"signature_pad": "^2.3.2",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.0.3",
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.2",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.14",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^13.0.6",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.4.4"
},
"whitelistedNonPeerDependencies": ["signature_pad"]
}
================================================
FILE: projects/angular2-signaturepad/README.md
================================================
# angular2-signaturepad
Angular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
<< THIS IS NO LONGER IN USE BY OWNER. PROBLEMS CAN AND DO EXIST. PRs ARE SUPER WELCOME, BUT I CAN NOT IDENTIFY WHAT YOUR ISSUES ARE, NOR WILL I CHANGE THINGS BECAUSE ANGULAR HAS CHANGED IN THE YEARS SINCE I WROTE THIS >>
## Install
`npm install angular2-signaturepad --save`
## Reference Implementation
* [Live Demo](http://lathonez.com/angular2-signaturepad-demo/)
* [Source](https://github.com/lathonez/angular2-signaturepad-demo)
## Usage example
API is identical to [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).
Options are as per [szimek/signature_pad](https://www.npmjs.com/package/signature_pad) with the following additions:
* canvasWidth: width of the canvas (px)
* canvasHeight: height of the canvas (px)
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
```typescript
// import into app module
import { SignaturePadModule } from 'angular2-signaturepad';
...
@NgModule({
declarations: [ ],
imports: [ SignaturePadModule ],
providers: [ ],
bootstrap: [ AppComponent ]
})
// then import for use in a component
import { Component, ViewChild } from 'angular2/core';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
@Component({
template: '<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>'
})
export class SignaturePadPage{
@ViewChild(SignaturePad) signaturePad: SignaturePad;
private signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
}
```
================================================
FILE: projects/angular2-signaturepad/karma.conf.js
================================================
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/angular2-signaturepad'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
================================================
FILE: projects/angular2-signaturepad/ng-package.json
================================================
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/angular2-signaturepad",
"lib": {
"entryFile": "src/public-api.ts"
}
}
================================================
FILE: projects/angular2-signaturepad/package.json
================================================
{
"name": "angular2-signaturepad",
"version": "3.0.4",
"description": "Angular2 Component wrapper for szimek / signature_pad",
"repository": {
"type": "git",
"url": "git+https://github.com/wulfsolter/angular2-signaturepad.git"
},
"keywords": [
"signature",
"sign",
"finger",
"canvas"
],
"author": "Wulf Solter <wulf@wulf.co.nz> (http://wulf.co.nz)",
"license": "MIT",
"bugs": {
"url": "https://github.com/wulfsolter/angular2-signaturepad/issues"
},
"homepage": "https://github.com/wulfsolter/angular2-signaturepad#readme",
"peerDependencies": {
"@angular/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"@angular/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"signature_pad": "2.3.2"
},
"dependencies": {
"tslib": "^2.0.0"
}
}
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.spec.ts
================================================
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SignaturePad } from './angular2-signaturepad.component';
describe('Angular2SignaturepadComponent', () => {
let component: SignaturePad;
let fixture: ComponentFixture<SignaturePad>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [SignaturePad],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SignaturePad);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.ts
================================================
import {
AfterContentInit,
Component,
ElementRef,
EventEmitter,
Input,
Output,
OnDestroy,
} from '@angular/core';
import * as SignaturePadNative from 'signature_pad';
export interface Point {
x: number;
y: number;
time: number;
}
export type PointGroup = Array<Point>;
@Component({
template: '<canvas></canvas>',
selector: 'signature-pad',
})
export class SignaturePad implements AfterContentInit, OnDestroy {
@Input() public options: any;
@Output() public onBeginEvent: EventEmitter<boolean>;
@Output() public onEndEvent: EventEmitter<boolean>;
private signaturePad: any;
private elementRef: ElementRef;
constructor(elementRef: ElementRef) {
// no op
this.elementRef = elementRef;
this.options = this.options || {};
this.onBeginEvent = new EventEmitter();
this.onEndEvent = new EventEmitter();
}
public ngAfterContentInit(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
if ((this.options as any).canvasHeight) {
canvas.height = (this.options as any).canvasHeight;
}
if ((this.options as any).canvasWidth) {
canvas.width = (this.options as any).canvasWidth;
}
this.signaturePad = new SignaturePadNative.default(canvas, this.options);
this.signaturePad.onBegin = this.onBegin.bind(this);
this.signaturePad.onEnd = this.onEnd.bind(this);
}
public ngOnDestroy(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
canvas.width = 0;
canvas.height = 0;
}
public resizeCanvas(): void {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
const ratio: number = Math.max(window.devicePixelRatio || 1, 1);
const canvas: any = this.signaturePad.canvas;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext('2d').scale(ratio, ratio);
this.signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Returns signature image as an array of point groups
public toData(): Array<PointGroup> {
if (this.signaturePad) {
return this.signaturePad.toData();
} else {
return [];
}
}
// Draws signature image from an array of point groups
public fromData(points: Array<PointGroup>): void {
this.signaturePad.fromData(points as any);
}
// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible paramters)
public toDataURL(imageType?: string, quality?: number): string {
return this.signaturePad.toDataURL(imageType, quality); // save image as data URL
}
// Draws signature image from data URL
public fromDataURL(dataURL: string, options: any = {}): void {
// set default height and width on read data from URL
if (
!options.hasOwnProperty('height') &&
(this.options as any).canvasHeight
) {
options.height = (this.options as any).canvasHeight;
}
if (!options.hasOwnProperty('width') && (this.options as any).canvasWidth) {
options.width = (this.options as any).canvasWidth;
}
this.signaturePad.fromDataURL(dataURL, options);
}
// Clears the canvas
public clear(): void {
this.signaturePad.clear();
}
// Returns true if canvas is empty, otherwise returns false
public isEmpty(): boolean {
return this.signaturePad.isEmpty();
}
// Unbinds all event handlers
public off(): void {
this.signaturePad.off();
}
// Rebinds all event handlers
public on(): void {
this.signaturePad.on();
}
// set an option on the signaturePad - e.g. set('minWidth', 50);
public set(option: string, value: any): void {
switch (option) {
case 'canvasHeight':
this.signaturePad.canvas.height = value;
break;
case 'canvasWidth':
this.signaturePad.canvas.width = value;
break;
default:
this.signaturePad[option] = value;
}
}
// notify subscribers on signature begin
public onBegin(): void {
this.onBeginEvent.emit(true);
}
// notify subscribers on signature end
public onEnd(): void {
this.onEndEvent.emit(true);
}
public queryPad(): any {
return this.signaturePad;
}
}
================================================
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.module.ts
================================================
import { NgModule } from '@angular/core';
import { SignaturePad } from './angular2-signaturepad.component';
@NgModule({
declarations: [SignaturePad],
imports: [],
exports: [SignaturePad],
})
export class SignaturePadModule {}
================================================
FILE: projects/angular2-signaturepad/src/public-api.ts
================================================
/*
* Public API Surface of angular2-signaturepad
*/
export * from './lib/angular2-signaturepad.component';
export * from './lib/angular2-signaturepad.module';
================================================
FILE: projects/angular2-signaturepad/src/test.ts
================================================
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
keys(): string[];
<T>(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
================================================
FILE: projects/angular2-signaturepad/tsconfig.lib.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
================================================
FILE: projects/angular2-signaturepad/tsconfig.lib.prod.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}
================================================
FILE: projects/angular2-signaturepad/tsconfig.spec.json
================================================
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
"src/test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
================================================
FILE: projects/angular2-signaturepad/tslint.json
================================================
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"lib",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"kebab-case"
]
}
}
================================================
FILE: signature-pad.ts
================================================
'use strict';
import {AfterContentInit, Component, ElementRef, EventEmitter, Input, Output, OnDestroy} from '@angular/core';
declare var require: any;
export interface Point {
x: number;
y: number;
time: number;
}
export type PointGroup = Array<Point>;
@Component({
template: '<canvas></canvas>',
selector: 'signature-pad',
})
export class SignaturePad implements AfterContentInit, OnDestroy {
@Input() public options: Object;
@Output() public onBeginEvent: EventEmitter<boolean>;
@Output() public onEndEvent: EventEmitter<boolean>;
private signaturePad: any;
private elementRef: ElementRef;
constructor(elementRef: ElementRef) {
// no op
this.elementRef = elementRef;
this.options = this.options || {};
this.onBeginEvent = new EventEmitter();
this.onEndEvent = new EventEmitter();
}
public ngAfterContentInit(): void {
const sp: any = require('signature_pad').default;
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
if ((this.options as any).canvasHeight) {
canvas.height = (this.options as any).canvasHeight;
}
if ((this.options as any).canvasWidth) {
canvas.width = (this.options as any).canvasWidth;
}
this.signaturePad = new sp(canvas, this.options);
this.signaturePad.onBegin = this.onBegin.bind(this);
this.signaturePad.onEnd = this.onEnd.bind(this);
}
public ngOnDestroy(): void {
const canvas: any = this.elementRef.nativeElement.querySelector('canvas');
canvas.width = 0;
canvas.height = 0;
}
public resizeCanvas(): void {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
const ratio: number = Math.max(window.devicePixelRatio || 1, 1);
const canvas: any = this.signaturePad._canvas;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext('2d').scale(ratio, ratio);
this.signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Returns signature image as an array of point groups
public toData(): Array<PointGroup> {
if (this.signaturePad) {
return this.signaturePad.toData();
} else {
return [];
}
}
// Draws signature image from an array of point groups
public fromData(points: Array<PointGroup>): void {
this.signaturePad.fromData(points);
}
// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible paramters)
public toDataURL(imageType?: string, quality?: number): string {
return this.signaturePad.toDataURL(imageType, quality); // save image as data URL
}
// Draws signature image from data URL
public fromDataURL(dataURL: string, options: any = {}): void {
// set default height and width on read data from URL
if (!options.hasOwnProperty('height') && (this.options as any).canvasHeight) {
options.height = (this.options as any).canvasHeight;
}
if (!options.hasOwnProperty('width') && (this.options as any).canvasWidth) {
options.width = (this.options as any).canvasWidth;
}
this.signaturePad.fromDataURL(dataURL, options);
}
// Clears the canvas
public clear(): void {
this.signaturePad.clear();
}
// Returns true if canvas is empty, otherwise returns false
public isEmpty(): boolean {
return this.signaturePad.isEmpty();
}
// Unbinds all event handlers
public off(): void {
this.signaturePad.off();
}
// Rebinds all event handlers
public on(): void {
this.signaturePad.on();
}
// set an option on the signaturePad - e.g. set('minWidth', 50);
public set(option: string, value: any): void {
switch (option) {
case 'canvasHeight':
this.signaturePad._canvas.height = value;
break;
case 'canvasWidth':
this.signaturePad._canvas.width = value;
break;
default:
this.signaturePad[option] = value;
}
}
// notify subscribers on signature begin
public onBegin(): void {
this.onBeginEvent.emit(true);
}
// notify subscribers on signature end
public onEnd(): void {
this.onEndEvent.emit(true);
}
public queryPad(): any {
return this.signaturePad;
}
}
================================================
FILE: tsconfig.json
================================================
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": ["es2018", "dom"],
"paths": {
"angular2-signaturepad": [
"dist/angular2-signaturepad/angular2-signaturepad",
"dist/angular2-signaturepad"
]
}
},
"angularCompilerOptions": {}
}
================================================
FILE: tslint.json
================================================
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"align": {
"options": [
"parameters",
"statements"
]
},
"array-type": false,
"arrow-return-shorthand": true,
"curly": true,
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": {
"options": [
"spaces"
]
},
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"quotemark": [
true,
"single"
],
"semicolon": {
"options": [
"always"
]
},
"space-before-function-paren": {
"options": {
"anonymous": "never",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}
},
"typedef": [
true,
"call-signature"
],
"typedef-whitespace": {
"options": [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
},
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case"
]
},
"whitespace": {
"options": [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true
}
}
gitextract_blae03qp/ ├── .editorconfig ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── angular.json ├── index.ts ├── package.json ├── projects/ │ └── angular2-signaturepad/ │ ├── README.md │ ├── karma.conf.js │ ├── ng-package.json │ ├── package.json │ ├── src/ │ │ ├── lib/ │ │ │ ├── angular2-signaturepad.component.spec.ts │ │ │ ├── angular2-signaturepad.component.ts │ │ │ └── angular2-signaturepad.module.ts │ │ ├── public-api.ts │ │ └── test.ts │ ├── tsconfig.lib.json │ ├── tsconfig.lib.prod.json │ ├── tsconfig.spec.json │ └── tslint.json ├── signature-pad.ts ├── tsconfig.json └── tslint.json
SYMBOL INDEX (40 symbols across 4 files)
FILE: index.ts
class SignaturePadModule (line 10) | class SignaturePadModule { }
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.ts
type Point (line 13) | interface Point {
type PointGroup (line 19) | type PointGroup = Array<Point>;
class SignaturePad (line 25) | class SignaturePad implements AfterContentInit, OnDestroy {
method constructor (line 33) | constructor(elementRef: ElementRef) {
method ngAfterContentInit (line 41) | public ngAfterContentInit(): void {
method ngOnDestroy (line 57) | public ngOnDestroy(): void {
method resizeCanvas (line 63) | public resizeCanvas(): void {
method toData (line 76) | public toData(): Array<PointGroup> {
method fromData (line 85) | public fromData(points: Array<PointGroup>): void {
method toDataURL (line 90) | public toDataURL(imageType?: string, quality?: number): string {
method fromDataURL (line 95) | public fromDataURL(dataURL: string, options: any = {}): void {
method clear (line 110) | public clear(): void {
method isEmpty (line 115) | public isEmpty(): boolean {
method off (line 120) | public off(): void {
method on (line 125) | public on(): void {
method set (line 130) | public set(option: string, value: any): void {
method onBegin (line 144) | public onBegin(): void {
method onEnd (line 149) | public onEnd(): void {
method queryPad (line 153) | public queryPad(): any {
FILE: projects/angular2-signaturepad/src/lib/angular2-signaturepad.module.ts
class SignaturePadModule (line 9) | class SignaturePadModule {}
FILE: signature-pad.ts
type Point (line 7) | interface Point {
type PointGroup (line 13) | type PointGroup = Array<Point>;
class SignaturePad (line 20) | class SignaturePad implements AfterContentInit, OnDestroy {
method constructor (line 29) | constructor(elementRef: ElementRef) {
method ngAfterContentInit (line 37) | public ngAfterContentInit(): void {
method ngOnDestroy (line 54) | public ngOnDestroy(): void {
method resizeCanvas (line 60) | public resizeCanvas(): void {
method toData (line 73) | public toData(): Array<PointGroup> {
method fromData (line 82) | public fromData(points: Array<PointGroup>): void {
method toDataURL (line 87) | public toDataURL(imageType?: string, quality?: number): string {
method fromDataURL (line 92) | public fromDataURL(dataURL: string, options: any = {}): void {
method clear (line 104) | public clear(): void {
method isEmpty (line 109) | public isEmpty(): boolean {
method off (line 114) | public off(): void {
method on (line 119) | public on(): void {
method set (line 124) | public set(option: string, value: any): void {
method onBegin (line 139) | public onBegin(): void {
method onEnd (line 144) | public onEnd(): void {
method queryPad (line 148) | public queryPad(): any {
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (30K chars).
[
{
"path": ".editorconfig",
"chars": 274,
"preview": "# Editor configuration, see https://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size ="
},
{
"path": ".gitignore",
"chars": 647,
"preview": "# See http://help.github.com/ignore-files/ for more about ignoring files.\n\n# compiled output\n/dist\n/tmp\n/out-tsc\n# Only "
},
{
"path": ".npmignore",
"chars": 155,
"preview": "# Node generated files\nnode_modules\nnpm-debug.log\n\n# OS generated files\nThumbs.db\n.DS_Store\n\n# Ignored files\n*.ts\n!*.d.t"
},
{
"path": "LICENSE",
"chars": 1078,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2016 Wulf Sölter\n\nPermission is hereby granted, free of charge, to any person obtai"
},
{
"path": "README.md",
"chars": 2383,
"preview": "# angular2-signaturepad\nAngular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).\n\n# "
},
{
"path": "angular.json",
"chars": 1196,
"preview": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \""
},
{
"path": "index.ts",
"chars": 222,
"preview": "import { NgModule } from '@angular/core';\nimport { SignaturePad } from './signature-pad';\n\n@NgModule({\n imports: [ ],\n "
},
{
"path": "package.json",
"chars": 1306,
"preview": "{\n \"name\": \"angular2-signaturepad\",\n \"version\": \"4.0.0\",\n \"scripts\": {\n \"ng\": \"ng\",\n \"start\": \"ng serve\",\n \""
},
{
"path": "projects/angular2-signaturepad/README.md",
"chars": 2310,
"preview": "# angular2-signaturepad\nAngular 2 component for [szimek/signature_pad](https://www.npmjs.com/package/signature_pad).\n\n<<"
},
{
"path": "projects/angular2-signaturepad/karma.conf.js",
"chars": 1120,
"preview": "// Karma configuration file, see link for more information\n// https://karma-runner.github.io/1.0/config/configuration-fi"
},
{
"path": "projects/angular2-signaturepad/ng-package.json",
"chars": 171,
"preview": "{\n \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n \"dest\": \"../../dist/angular2-signaturepad\",\n \""
},
{
"path": "projects/angular2-signaturepad/package.json",
"chars": 853,
"preview": "{\n \"name\": \"angular2-signaturepad\",\n \"version\": \"3.0.4\",\n \"description\": \"Angular2 Component wrapper for szimek / sig"
},
{
"path": "projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.spec.ts",
"chars": 634,
"preview": "import { ComponentFixture, TestBed } from '@angular/core/testing';\n\nimport { SignaturePad } from './angular2-signaturepa"
},
{
"path": "projects/angular2-signaturepad/src/lib/angular2-signaturepad.component.ts",
"chars": 4345,
"preview": "import {\n AfterContentInit,\n Component,\n ElementRef,\n EventEmitter,\n Input,\n Output,\n OnDestroy,\n} from '@angular"
},
{
"path": "projects/angular2-signaturepad/src/lib/angular2-signaturepad.module.ts",
"chars": 233,
"preview": "import { NgModule } from '@angular/core';\nimport { SignaturePad } from './angular2-signaturepad.component';\n\n@NgModule({"
},
{
"path": "projects/angular2-signaturepad/src/public-api.ts",
"chars": 162,
"preview": "/*\n * Public API Surface of angular2-signaturepad\n */\n\nexport * from './lib/angular2-signaturepad.component';\nexport * f"
},
{
"path": "projects/angular2-signaturepad/src/test.ts",
"chars": 808,
"preview": "// This file is required by karma.conf.js and loads recursively all the .spec and framework files\n\nimport 'zone.js';\nimp"
},
{
"path": "projects/angular2-signaturepad/tsconfig.lib.json",
"chars": 540,
"preview": "/* To learn more about this file see: https://angular.io/config/tsconfig. */\n{\n \"extends\": \"../../tsconfig.json\",\n \"co"
},
{
"path": "projects/angular2-signaturepad/tsconfig.lib.prod.json",
"chars": 240,
"preview": "/* To learn more about this file see: https://angular.io/config/tsconfig. */\n{\n \"extends\": \"./tsconfig.lib.json\",\n \"co"
},
{
"path": "projects/angular2-signaturepad/tsconfig.spec.json",
"chars": 309,
"preview": "/* To learn more about this file see: https://angular.io/config/tsconfig. */\n{\n \"extends\": \"../../tsconfig.json\",\n \"co"
},
{
"path": "projects/angular2-signaturepad/tslint.json",
"chars": 247,
"preview": "{\n \"extends\": \"../../tslint.json\",\n \"rules\": {\n \"directive-selector\": [\n true,\n \"attribute\",\n \"lib\","
},
{
"path": "signature-pad.ts",
"chars": 4330,
"preview": "'use strict';\n\nimport {AfterContentInit, Component, ElementRef, EventEmitter, Input, Output, OnDestroy} from '@angular/c"
},
{
"path": "tsconfig.json",
"chars": 555,
"preview": "{\n \"compileOnSave\": false,\n \"compilerOptions\": {\n \"baseUrl\": \"./\",\n \"outDir\": \"./dist/out-tsc\",\n \"sourceMap\":"
},
{
"path": "tslint.json",
"chars": 2992,
"preview": "{\n \"extends\": \"tslint:recommended\",\n \"rulesDirectory\": [\n \"codelyzer\"\n ],\n \"rules\": {\n \"align\": {\n \"optio"
}
]
About this extraction
This page contains the full source code of the wulfsolter/angular2-signaturepad GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (26.5 KB), approximately 7.6k tokens, and a symbol index with 40 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.