add typescript
This commit is contained in:
parent
76c1d9f380
commit
d0d845bfd4
@ -6,6 +6,17 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Remove="Scripts\app.ts" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Scripts\app.ts">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.2.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
|
||||
await JS.InvokeVoidAsync("loadPDFFromUrl", "#container", $"/api/download/{document.Id}");
|
||||
var module = await JS.InvokeAsync<IJSObjectReference>("import", "./js/app.js");
|
||||
await module.InvokeVoidAsync("App.loadPDFFromUrl", "#container", $"/api/download/{document.Id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
EnvelopeGenerator.Web/Scripts/app.ts
Normal file
48
EnvelopeGenerator.Web/Scripts/app.ts
Normal file
@ -0,0 +1,48 @@
|
||||
//import PSPDFKit, { Instance } from 'index.d.ts';
|
||||
import PSPDFKitType from "./index";
|
||||
import { Instance } from "./index";
|
||||
|
||||
declare const PSPDFKit: typeof PSPDFKitType
|
||||
|
||||
export class App {
|
||||
public static loadPDFFromUrl (container: string, url: string): void {
|
||||
console.log("Loading PSPDFKit..");
|
||||
|
||||
fetch(url, { credentials: "include" })
|
||||
.then(res => res.arrayBuffer())
|
||||
.then(arrayBuffer => App.loadPSPDFKit(arrayBuffer, container))
|
||||
.then(instance => {
|
||||
console.log("PSPDFKit loaded!")
|
||||
console.log(instance)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
private static loadPSPDFKit(arrayBuffer: ArrayBuffer, container: string) {
|
||||
PSPDFKit.load({
|
||||
container: container,
|
||||
document: arrayBuffer
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This function will be called in the ShowEnvelope.razor page
|
||||
// and will trigger loading of the Editor Interface
|
||||
//const loadPDFFromUrl = function (container: string, url: string): void {
|
||||
// console.log("Loading PSPDFKit..");
|
||||
|
||||
// fetch(url, { credentials: "include" })
|
||||
// .then(res => res.arrayBuffer())
|
||||
// .then(arrayBuffer => loadPSPDFKit(arrayBuffer, container))
|
||||
// .then(configurePSPDFKit)
|
||||
// .then(instance => {
|
||||
// console.log("PSPDFKit loaded!")
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error(error.message);
|
||||
// });
|
||||
//}
|
||||
|
||||
8599
EnvelopeGenerator.Web/Scripts/index.d.ts
vendored
Normal file
8599
EnvelopeGenerator.Web/Scripts/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
EnvelopeGenerator.Web/package.json
Normal file
6
EnvelopeGenerator.Web/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"name": "asp.net",
|
||||
"private": true,
|
||||
"devDependencies": { }
|
||||
}
|
||||
20
EnvelopeGenerator.Web/tsconfig.json
Normal file
20
EnvelopeGenerator.Web/tsconfig.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": false,
|
||||
"outDir": "wwwroot/js",
|
||||
"removeComments": false,
|
||||
"module": "ES2015",
|
||||
"moduleResolution": "Classic",
|
||||
"sourceMap": true,
|
||||
"target": "es5",
|
||||
"lib": ["ES2015", "DOM"]
|
||||
},
|
||||
"include": [
|
||||
"Scripts/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@ -1,24 +1,41 @@
|
||||
// This function will be called in the ShowEnvelope.razor page
|
||||
// and will trigger loading of the Editor Interface
|
||||
function loadPDFFromUrl(container, url) {
|
||||
var App = /** @class */ (function () {
|
||||
function App() {
|
||||
}
|
||||
App.loadPDFFromUrl = function (container, url) {
|
||||
console.log("Loading PSPDFKit..");
|
||||
console.log(PSPDFKit);
|
||||
|
||||
fetch(url, { credentials: "include" })
|
||||
.then(res => res.arrayBuffer())
|
||||
.then(arrayBuffer => PSPDFKit.load({
|
||||
container: container,
|
||||
document: arrayBuffer
|
||||
}))
|
||||
.then(instance => {
|
||||
console.log("PSPDFKit loaded", instance)
|
||||
configurePSPDFKit(instance);
|
||||
.then(function (res) { return res.arrayBuffer(); })
|
||||
.then(function (arrayBuffer) { return App.loadPSPDFKit(arrayBuffer, container); })
|
||||
.then(function (instance) {
|
||||
console.log("PSPDFKit loaded!");
|
||||
console.log(instance);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch(function (error) {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function configurePSPDFKit(instance) {
|
||||
console.log(instance);
|
||||
}
|
||||
};
|
||||
App.loadPSPDFKit = function (arrayBuffer, container) {
|
||||
PSPDFKit.load({
|
||||
container: container,
|
||||
document: arrayBuffer
|
||||
});
|
||||
};
|
||||
return App;
|
||||
}());
|
||||
export { App };
|
||||
// This function will be called in the ShowEnvelope.razor page
|
||||
// and will trigger loading of the Editor Interface
|
||||
//const loadPDFFromUrl = function (container: string, url: string): void {
|
||||
// console.log("Loading PSPDFKit..");
|
||||
// fetch(url, { credentials: "include" })
|
||||
// .then(res => res.arrayBuffer())
|
||||
// .then(arrayBuffer => loadPSPDFKit(arrayBuffer, container))
|
||||
// .then(configurePSPDFKit)
|
||||
// .then(instance => {
|
||||
// console.log("PSPDFKit loaded!")
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error(error.message);
|
||||
// });
|
||||
//}
|
||||
//# sourceMappingURL=app.js.map
|
||||
1
EnvelopeGenerator.Web/wwwroot/js/app.js.map
Normal file
1
EnvelopeGenerator.Web/wwwroot/js/app.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../Scripts/app.ts"],"names":[],"mappings":"AAMA;IAAA;IAuBA,CAAC;IAtBiB,kBAAc,GAA5B,UAA8B,SAAiB,EAAE,GAAW;QACxD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAElC,KAAK,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;aACjC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,EAAE,EAAjB,CAAiB,CAAC;aAC9B,IAAI,CAAC,UAAA,WAAW,IAAI,OAAA,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAxC,CAAwC,CAAC;aAC7D,IAAI,CAAC,UAAA,QAAQ;YACV,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;YAC/B,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC,CAAC;aACD,KAAK,CAAC,UAAA,KAAK;YACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACX,CAAC;IAEc,gBAAY,GAA3B,UAA4B,WAAwB,EAAE,SAAiB;QACnE,QAAQ,CAAC,IAAI,CAAC;YACV,SAAS,EAAE,SAAS;YACpB,QAAQ,EAAE,WAAW;SACxB,CAAC,CAAA;IACN,CAAC;IAEL,UAAC;AAAD,CAAC,AAvBD,IAuBC;;AAED,8DAA8D;AAC9D,mDAAmD;AACnD,0EAA0E;AAC1E,wCAAwC;AAExC,4CAA4C;AAC5C,yCAAyC;AACzC,oEAAoE;AACpE,kCAAkC;AAClC,6BAA6B;AAC7B,6CAA6C;AAC7C,YAAY;AACZ,2BAA2B;AAC3B,2CAA2C;AAC3C,aAAa;AACb,GAAG"}
|
||||
Loading…
x
Reference in New Issue
Block a user