diff -Nru zim-0.73.5-SNAPSHOT/debian/changelog zim-0.73.5-SNAPSHOT/debian/changelog --- zim-0.73.5-SNAPSHOT/debian/changelog 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/debian/changelog 2021-07-13 20:21:43.000000000 +0000 @@ -1,8 +1,8 @@ -zim (0.73.5-SNAPSHOT-t202107081900~ubuntu20.10.1) groovy; urgency=low +zim (0.73.5-SNAPSHOT-t202107131839~ubuntu20.10.1) groovy; urgency=low * Auto build. - -- Jaap Karssenberg Thu, 08 Jul 2021 22:23:50 +0000 + -- Jaap Karssenberg Tue, 13 Jul 2021 20:21:43 +0000 zim (0.73.5) unstable; urgency=medium diff -Nru zim-0.73.5-SNAPSHOT/debian/git-build-recipe.manifest zim-0.73.5-SNAPSHOT/debian/git-build-recipe.manifest --- zim-0.73.5-SNAPSHOT/debian/git-build-recipe.manifest 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/debian/git-build-recipe.manifest 2021-07-13 20:21:43.000000000 +0000 @@ -1,2 +1,2 @@ -# git-build-recipe format 0.4 deb-version {debupstream}-SNAPSHOT-t202107081900 -lp:zim git-commit:2f6269fe61969a899ab788e75327ea72d50eed4b +# git-build-recipe format 0.4 deb-version {debupstream}-SNAPSHOT-t202107131839 +lp:zim git-commit:c6fe2c66a2375a727906a13f01b1a7ab0f15117a diff -Nru zim-0.73.5-SNAPSHOT/tests/clipboard.py zim-0.73.5-SNAPSHOT/tests/clipboard.py --- zim-0.73.5-SNAPSHOT/tests/clipboard.py 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/tests/clipboard.py 2021-07-13 20:21:43.000000000 +0000 @@ -245,6 +245,13 @@ newtree = Clipboard.get_parsetree(self.notebook, Path('Test')) self.assertEqual(newtree.tostring(), wanted) + def testCopyPageLinkPasteAsParseTreeInSamePage(self): + page = self.notebook.get_page(Path('Test:wiki')) + Clipboard.set_pagelink(self.notebook, page) + wanted = '''\nwiki''' + newtree = Clipboard.get_parsetree(self.notebook, page) + self.assertEqual(newtree.tostring(), wanted) + def testCopyPageLinkPasteAsParseTreeWithShortName(self): self.notebook.config['Notebook']['short_links'] = True page = self.notebook.get_page(Path('Test:wiki:Foo')) @@ -260,6 +267,13 @@ newtree = Clipboard.get_parsetree(self.notebook, Path('Test')) self.assertEqual(newtree.tostring(), wanted) + def testCopyPageLinkWithAnchorPasteAsParseTreeInSamePage(self): + page = self.notebook.get_page(Path('Test:wiki')) + Clipboard.set_pagelink(self.notebook, page, 'anchor') + wanted = '''\n#anchor''' + newtree = Clipboard.get_parsetree(self.notebook, page) + self.assertEqual(newtree.tostring(), wanted) + def testCopyPageLinkWithAnchorAndTextPasteAsParseTree(self): page = self.notebook.get_page(Path('Test:wiki')) Clipboard.set_pagelink(self.notebook, page, 'anchor', 'My anchor') diff -Nru zim-0.73.5-SNAPSHOT/zim/gui/clipboard.py zim-0.73.5-SNAPSHOT/zim/gui/clipboard.py --- zim-0.73.5-SNAPSHOT/zim/gui/clipboard.py 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/zim/gui/clipboard.py 2021-07-13 20:21:43.000000000 +0000 @@ -687,12 +687,15 @@ text += '#' + self.anchor else: text = link + + # Same logic as _set_attributes_to_resolve_links() but no need to resolve again builder = ParseTreeBuilder() builder.start(FORMATTEDTEXT) - builder.append(LINK, {'href': link}, text) + builder.append(LINK, {'href': link, '_href': self.path.name}, text) builder.end(FORMATTEDTEXT) parsetree = builder.get_parsetree() - _set_attributes_to_resolve_links(parsetree, self.notebook, self.path) + parsetree._set_root_attrib('notebook', self.notebook.interwiki) + parsetree._set_root_attrib('page', '-') # force resolve on paste also on same page return parsetree.tostring() else: raise ValueError('Unknown target id %i' % targetid) diff -Nru zim-0.73.5-SNAPSHOT/zim/gui/pageview/__init__.py zim-0.73.5-SNAPSHOT/zim/gui/pageview/__init__.py --- zim-0.73.5-SNAPSHOT/zim/gui/pageview/__init__.py 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/zim/gui/pageview/__init__.py 2021-07-13 20:21:43.000000000 +0000 @@ -4687,12 +4687,43 @@ def click_anchor(self): '''Show popover for anchor under the cursor''' iter, coords = self._get_pointer_location() - if iter: - pixbuf = self._get_pixbuf_at_pointer(iter, coords) - if pixbuf and hasattr(pixbuf, 'zim_type') and pixbuf.zim_type == 'anchor': - return False # TODO: add popover wo copy to clipboard and edit the anchor - else: - return False + if not iter: + return False + + pixbuf = self._get_pixbuf_at_pointer(iter, coords) + if not (pixbuf and hasattr(pixbuf, 'zim_type') and pixbuf.zim_type == 'anchor'): + return False + + # Show popover with achor name and option to copy link + popover = Gtk.Popover() + popover.set_relative_to(self) + rect = Gdk.Rectangle() + rect.x, rect.y = self.get_pointer() + rect.width, rect.height = 1, 1 + popover.set_pointing_to(rect) + + name = pixbuf.zim_attrib['name'] + def _copy_link_to_anchor(o): + buffer = self.get_buffer() + notebook, page = buffer.notebook, buffer.page + Clipboard.set_pagelink(notebook, page, name) + SelectionClipboard.set_pagelink(notebook, page, name) + popover.popdown() + + hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 12) + hbox.set_border_width(3) + label = Gtk.Label() + label.set_markup('#%s' %name) + hbox.add(label) + button = Gtk.Button.new_from_icon_name('edit-copy-symbolic', Gtk.IconSize.BUTTON) + button.set_tooltip_text(_("Copy link to clipboard")) # T: tooltip for button in anchor popover + button.connect('clicked', _copy_link_to_anchor) + hbox.add(button) + popover.add(hbox) + popover.show_all() + popover.popup() + + return True def get_visual_home_positions(self, iter): '''Get the TextIters for the visuale start of the line diff -Nru zim-0.73.5-SNAPSHOT/zim/notebook/notebook.py zim-0.73.5-SNAPSHOT/zim/notebook/notebook.py --- zim-0.73.5-SNAPSHOT/zim/notebook/notebook.py 2021-07-08 22:23:50.000000000 +0000 +++ zim-0.73.5-SNAPSHOT/zim/notebook/notebook.py 2021-07-13 20:21:43.000000000 +0000 @@ -825,14 +825,17 @@ def _update_link_tag(self, elt, source, target, oldhref): if oldhref.rel == HREF_REL_ABSOLUTE: # prefer to keep absolute links newhref = HRef(HREF_REL_ABSOLUTE, target.name) + elif source == target and oldhref.anchor: + newhref = HRef(HREF_REL_FLOATING, '', oldhref.anchor) else: newhref = self.pages.create_link(source, target) newhref.anchor = oldhref.anchor - text = newhref.to_wiki_link() + link = newhref.to_wiki_link() + if elt.gettext() == elt.get('href'): - elt[:] = [text] + elt[:] = [link] elif elt.gettext() == oldhref.parts()[-1] and len(elt) == 1: # We are using short links and the link text was short link # and there were no sub-node (like bold text) that would be cancelled. @@ -842,7 +845,8 @@ short += '#' + newhref.anchor elt[:] = [short] # 'Journal:2020:01:20' -> '20' - elt.set('href', text) + elt.set('href', link) + return elt @assert_index_uptodate