-
Notifications
You must be signed in to change notification settings - Fork 24
Add attachment support for nextcloud-text #107
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /node_modules/ |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| namespace OCA\Drawio\Listeners; | ||
|
|
||
| use OCA\Drawio\AppInfo\Application; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\Files\Template\RegisterTemplateCreatorEvent; | ||
| use OCP\Files\Template\TemplateFileCreator; | ||
| use OCP\IL10N; | ||
|
|
||
| final class RegisterTemplateCreatorListener implements IEventListener { | ||
| public function __construct( | ||
| private IL10N $l10n, | ||
| ) { | ||
| } | ||
|
|
||
| public function handle(Event $event): void { | ||
| if (!($event instanceof RegisterTemplateCreatorEvent)) { | ||
| return; | ||
| } | ||
| $event->getTemplateManager()->registerTemplateFileCreator(function () { | ||
| $drawio = new TemplateFileCreator(Application::APP_ID, $this->l10n->t('New draw.io Diagram'), '.drawio'); | ||
| $drawio->addMimetype('application/x-drawio'); | ||
| $drawio->setIconSvgInline(file_get_contents(__DIR__ . '/../../img/drawio.svg')); | ||
| $drawio->setActionLabel($this->l10n->t('New draw.io Diagram')); | ||
| return $drawio; | ||
| }); | ||
| $event->getTemplateManager()->registerTemplateFileCreator(function () { | ||
| $dwb = new TemplateFileCreator(Application::APP_ID, $this->l10n->t('New draw.io Whiteboard'), '.dwb'); | ||
| $dwb->addMimetype('application/x-drawio-wb'); | ||
| $dwb->setIconSvgInline(file_get_contents(__DIR__ . '/../../img/dwb.svg')); | ||
| $dwb->setActionLabel($this->l10n->t('New draw.io Whiteboard')); | ||
| return $dwb; | ||
| }); | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||
| const generateRandom = () => | ||||||
| Math.random() | ||||||
| .toString(36) | ||||||
| .replace(/[^a-z]+/g, '') | ||||||
| .substr(0, 10); | ||||||
|
|
||||||
| export default { | ||||||
| name: 'drawio-preview', | ||||||
| props: { | ||||||
| filename: { type: String, default: null }, | ||||||
| fileid: { type: Number, default: null }, | ||||||
| isEmbedded: { type: Boolean, default: false }, | ||||||
| }, | ||||||
| render(createElement) { | ||||||
| this.$emit('update:loaded', true); | ||||||
| const rnd = generateRandom(); | ||||||
| const imgUrl = `/index.php/core/preview?fileId=${this.fileid}&x=1000&y=1000&a=1&${rnd}`; | ||||||
| const padding = 15; | ||||||
|
|
||||||
| this.$nextTick(() => { | ||||||
| const el = document.getElementById( | ||||||
| `drawoi-${rnd}`, | ||||||
| ); | ||||||
| el.addEventListener('click', () => { | ||||||
| this.openEditor(); | ||||||
| }); | ||||||
| }); | ||||||
| const img = new Image(); | ||||||
| img.onload = function() { | ||||||
| const el = document.getElementById( | ||||||
| `drawoi-${rnd}`, | ||||||
|
||||||
| ); | ||||||
| const img = document.createElement('div'); | ||||||
| img.style.height = `${this.height}px`; | ||||||
| img.style.width = `100%`; | ||||||
| img.style.background = `url(${imgUrl}) no-repeat center/contain`; | ||||||
| img.style.cursor = 'pointer', | ||||||
|
||||||
| img.style.cursor = 'pointer', | |
| img.style.cursor = 'pointer'; |
Copilot
AI
Oct 25, 2025
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.
Corrected spelling of 'drawoi' to 'drawio'.
Copilot
AI
Oct 25, 2025
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.
Using loose equality (==) and unnecessary String() conversion. The comparison should use strict equality (===) and String() wrapper is redundant since the result will already be a boolean.
| return String(extension == 'dwb'); | |
| return extension === 'dwb'; |
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.
Corrected spelling of 'drawoi' to 'drawio'.