-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d81f7e8
commit 36ef6f4
Showing
15 changed files
with
248 additions
and
46 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/threat-composer-app/src/utils/convertToDocx/components/Table.ts
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** ******************************************************************************************************************* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************************************************** */ | ||
import { Table as DocxTable, ITableOptions } from 'docx'; | ||
|
||
class Table extends DocxTable { | ||
constructor(opts: ITableOptions) { | ||
super({ | ||
...opts, | ||
margins: { | ||
top: 16, | ||
bottom: 16, | ||
left: 16, | ||
right: 16, | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export default Table; |
31 changes: 31 additions & 0 deletions
31
packages/threat-composer-app/src/utils/convertToDocx/components/TableHeaderCell.ts
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** ******************************************************************************************************************* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************************************************** */ | ||
import { TableCell, Paragraph, IParagraphOptions } from 'docx'; | ||
|
||
class TableHeaderCell extends TableCell { | ||
constructor(paragraph: string | IParagraphOptions) { | ||
super({ | ||
children: [new Paragraph(paragraph)], | ||
verticalAlign: 'center', | ||
shading: { | ||
fill: '000000', | ||
color: 'FFFFFF', | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export default TableHeaderCell; |
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
6 changes: 4 additions & 2 deletions
6
packages/threat-composer-app/src/utils/convertToDocx/fetchImage.ts
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
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
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
54 changes: 54 additions & 0 deletions
54
packages/threat-composer-app/src/utils/convertToDocx/getImage.ts
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** ******************************************************************************************************************* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************************************************** */ | ||
import { ExternalHyperlink, ImageRun, Paragraph } from 'docx'; | ||
import fetchImage from './fetchImage'; | ||
|
||
const getImage = async (imageUrl: string) => { | ||
const image = await fetchImage(imageUrl); | ||
|
||
if (imageUrl.startsWith('https://') || imageUrl.startsWith('http://')) { | ||
return new Paragraph({ | ||
children: [ | ||
new ExternalHyperlink({ | ||
link: imageUrl, | ||
children: [ | ||
new ImageRun({ | ||
data: image.image, | ||
transformation: { | ||
width: image.width, | ||
height: image.height, | ||
}, | ||
}), | ||
], | ||
}), | ||
], | ||
}); | ||
} | ||
|
||
return new Paragraph({ | ||
children: [ | ||
new ImageRun({ | ||
data: image.image, | ||
transformation: { | ||
width: image.width, | ||
height: image.height, | ||
}, | ||
}), | ||
], | ||
}); | ||
}; | ||
|
||
export default getImage; |
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
Oops, something went wrong.