Skip to content
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

Support alignment #21

Open
mforkel opened this issue Jan 5, 2022 · 1 comment
Open

Support alignment #21

mforkel opened this issue Jan 5, 2022 · 1 comment

Comments

@mforkel
Copy link

mforkel commented Jan 5, 2022

The plugin seems to have no support for aligning the pasted image.

A simplistic implementation could use the media manager's alignment settings similar to what dw_mediamanager_item_select does in lib/scripts/media.js, e.g.:

--- script.js.orig      2018-05-03 09:07:42.000000000 +0200
+++ script.js   2022-01-05 10:34:55.594361457 +0100
@@ -37,8 +37,14 @@
 
                     // insert syntax and close dialog
                     success: function (data) {
+                        var alignleft = '';
+                        var alignright = '';
+                        if (dw_mediamanager.align !== '1') {
+                            alignleft = dw_mediamanager.align === '2' ? '' : ' ';
+                            alignright = dw_mediamanager.align === '4' ? '' : ' ';
+                        }
                         $box.find('.content').addClass('success').text(data.message);
-                        insertAtCarret('wiki__text', '{{:' + data.id + '}}');
+                        insertAtCarret('wiki__text', '{{' + alignleft + ':' + data.id + alignright + '|}}');
                         $box.delay(500).fadeOut(500, function () {
                             $box.dialog('destroy').remove()
                         });

But I think it would be cleaner to make alignment a function of dw_mediamanager with its default settings accessible in the DokuWiki configuration and additional settings for the imgpaste plugin.

@splitbrain
Copy link
Member

I agree some setting for the default syntax (nolink, detail, alignment, ...) should be added to implement this correctly.

The plugin now supports other media (non-images) as well. Ideally PDFs shouldn't get any alignment.

PR welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants