diff --git a/src/applications/phriction/controller/PhrictionMarkupPreviewController.php b/src/applications/phriction/controller/PhrictionMarkupPreviewController.php index 7e56436dbb..a0964c53c4 100644 --- a/src/applications/phriction/controller/PhrictionMarkupPreviewController.php +++ b/src/applications/phriction/controller/PhrictionMarkupPreviewController.php @@ -3,13 +3,30 @@ final class PhrictionMarkupPreviewController extends PhabricatorController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); $text = $request->getStr('text'); $slug = $request->getStr('slug'); + $document = id(new PhrictionDocumentQuery()) + ->setViewer($viewer) + ->withSlugs(array($slug)) + ->needContent(true) + ->executeOne(); + if (!$document) { + $document = PhrictionDocument::initializeNewDocument( + $viewer, + $slug); + + $content = id(new PhrictionContent()) + ->setSlug($slug); + + $document + ->setPHID($document->generatePHID()) + ->attachContent($content); + } + $output = PhabricatorMarkupEngine::renderOneObject( id(new PhabricatorMarkupOneOff()) ->setPreserveLinebreaks(true) @@ -17,10 +34,7 @@ final class PhrictionMarkupPreviewController ->setContent($text), 'default', $viewer, - array( - 'phriction.isPreview' => true, - 'phriction.slug' => $slug, - )); + $document); return id(new AphrontAjaxResponse()) ->setContent($output); diff --git a/src/applications/phriction/markup/PhrictionRemarkupRule.php b/src/applications/phriction/markup/PhrictionRemarkupRule.php index 11994e0aa5..8394b23218 100644 --- a/src/applications/phriction/markup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php @@ -273,13 +273,6 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { return null; } - // Handle content when it's a preview for the Phriction editor. - if (is_array($context)) { - if (idx($context, 'phriction.isPreview')) { - return idx($context, 'phriction.slug'); - } - } - if ($context instanceof PhrictionContent) { return $context->getSlug(); }