diff --git a/src/applications/phriction/controller/PhrictionMarkupPreviewController.php b/src/applications/phriction/controller/PhrictionMarkupPreviewController.php --- 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 @@ ->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 --- a/src/applications/phriction/markup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php @@ -273,13 +273,6 @@ 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(); }