From 25285991707788ef2736de7626b7b083e341665d Mon Sep 17 00:00:00 2001 From: Anna Dabrowska Date: Wed, 8 Nov 2023 14:48:22 +0100 Subject: [PATCH] Fix warnings --- parser/InternalLinkNode.php | 8 +++++--- parser/LinkNode.php | 8 +++++++- script.js | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/parser/InternalLinkNode.php b/parser/InternalLinkNode.php index 71c74190..b7f09b20 100644 --- a/parser/InternalLinkNode.php +++ b/parser/InternalLinkNode.php @@ -2,6 +2,8 @@ namespace dokuwiki\plugin\prosemirror\parser; +use dokuwiki\File\PageResolver; + class InternalLinkNode extends LinkNode { public function toSyntax() @@ -43,10 +45,10 @@ public static function resolveLink($inner, $curId) { if (count($parts) === 2) { $params = $parts[1]; } - $ns = getNS($curId); $xhtml_renderer = p_get_renderer('xhtml'); $default = $xhtml_renderer->_simpleTitle($parts[0]); - resolve_pageid($ns, $resolvedPageId, $exists); + $resolver = new PageResolver($curId); + $resolvedPageId = $resolver->resolveId($resolvedPageId); if (useHeading('content')) { $heading = p_get_first_heading($resolvedPageId); @@ -59,7 +61,7 @@ public static function resolveLink($inner, $curId) { return [ 'id' => $resolvedPageId, - 'exists' => $exists, + 'exists' => page_exists($resolvedPageId), 'heading' => $heading, 'url' => $url, ]; diff --git a/parser/LinkNode.php b/parser/LinkNode.php index e9fca34e..91f61bf7 100644 --- a/parser/LinkNode.php +++ b/parser/LinkNode.php @@ -2,6 +2,8 @@ namespace dokuwiki\plugin\prosemirror\parser; +use dokuwiki\File\MediaResolver; + abstract class LinkNode extends Node implements InlineNodeInterface { @@ -128,7 +130,11 @@ public static function resolveImageTitle($pageId, $imageId, $title = null, $alig $xhtml_renderer = p_get_renderer('xhtml'); $src = $imageId; if (!media_isexternal($src)) { - resolve_mediaid(getNS($pageId), $src, $exists); + $resolver = new MediaResolver(getNS($pageId)); + $media = $resolver->resolveId($src); + if (!media_exists($media)) { + return ''; + } } return $xhtml_renderer->_media( $src, diff --git a/script.js b/script.js index 581b2587..8ae7dfb4 100644 --- a/script.js +++ b/script.js @@ -185,7 +185,9 @@ function menubar() { threshold: [0, 1] } ); - observer.observe(editorswitch); + if (editorswitch && menubar) { + observer.observe(editorswitch); + } }