diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7769ef6..3915059 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1,68 +1,71 @@ 2, 'class' => array( 'Diagram' => 'storage/Diagram.php', 'DiagramApplication' => 'application/DiagramApplication.php', 'DiagramCelerityResources' => 'celerity/DiagramCelerityResources.php', 'DiagramContentTransaction' => 'xaction/DiagramContentTransaction.php', 'DiagramController' => 'controller/DiagramController.php', 'DiagramDAO' => 'storage/DiagramDAO.php', 'DiagramPHIDType' => 'phid/DiagramPHIDType.php', 'DiagramPatchList' => 'storage/patch/DiagramPatchList.php', 'DiagramReplyHandler' => 'mail/DiagramReplyHandler.php', 'DiagramSchemaSpec' => 'storage/DiagramSchemaSpec.php', 'DiagramSearchConduitAPIMethod' => 'conduit/DiagramSearchConduitAPIMethod.php', 'DiagramTransaction' => 'storage/DiagramTransaction.php', 'DiagramTransactionEditor' => 'editor/DiagramTransactionEditor.php', 'DiagramTransactionType' => 'xaction/DiagramTransactionType.php', 'DiagramUploadConduitAPIMethod' => 'conduit/DiagramUploadConduitAPIMethod.php', 'DiagramVersion' => 'storage/DiagramVersion.php', 'PhabricatorDiagramQuery' => 'query/PhabricatorDiagramQuery.php', 'PhabricatorDiagramTransactionQuery' => 'query/PhabricatorDiagramTransactionQuery.php', 'PhabricatorDiagramVersionQuery' => 'query/PhabricatorDiagramVersionQuery.php', 'PhabricatorRemarkupDiagramRule' => 'remarkup/PhabricatorRemarkupDiagramRule.php', 'PlainHtmlWebpageResponse' => 'response/PlainHtmlWebpageResponse.php', ), 'function' => array(), 'xmap' => array( 'Diagram' => array( 'DiagramDAO', 'PhabricatorApplicationTransactionInterface', 'PhabricatorDestructibleInterface', 'PhabricatorPolicyInterface', 'PhabricatorSubscribableInterface', ), 'DiagramApplication' => 'PhabricatorApplication', 'DiagramCelerityResources' => 'CelerityResourcesOnDisk', 'DiagramContentTransaction' => 'DiagramTransactionType', 'DiagramController' => 'PhabricatorController', 'DiagramDAO' => 'PhabricatorLiskDAO', 'DiagramPHIDType' => 'PhabricatorPHIDType', 'DiagramPatchList' => 'PhabricatorSQLPatchList', 'DiagramReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'DiagramSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'DiagramSearchConduitAPIMethod' => 'ConduitAPIMethod', 'DiagramTransaction' => 'PhabricatorModularTransaction', 'DiagramTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'DiagramTransactionType' => 'PhabricatorModularTransactionType', 'DiagramUploadConduitAPIMethod' => 'ConduitAPIMethod', 'DiagramVersion' => array( 'DiagramDAO', 'PhabricatorDestructibleInterface', 'PhabricatorPolicyInterface', ), 'PhabricatorDiagramQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorDiagramTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorDiagramVersionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorRemarkupDiagramRule' => 'PhabricatorObjectRemarkupRule', + 'PhabricatorRemarkupDiagramRule' => array( + 'PhabricatorObjectRemarkupRule', + 'RemarkupSyntaxDocumentationProvider', + ), 'PlainHtmlWebpageResponse' => 'AphrontHTMLResponse', ), )); diff --git a/src/remarkup/PhabricatorRemarkupDiagramRule.php b/src/remarkup/PhabricatorRemarkupDiagramRule.php index c9c362f..b0e7be5 100644 --- a/src/remarkup/PhabricatorRemarkupDiagramRule.php +++ b/src/remarkup/PhabricatorRemarkupDiagramRule.php @@ -1,103 +1,128 @@ getEngine()->getConfig('viewer'); $objects = id(new PhabricatorDiagramVersionQuery()) ->setViewer($viewer) ->withDiagramIDs($ids) ->execute(); return $objects; } protected function renderObjectEmbed( $diagram, PhabricatorObjectHandle $handle, $options) { if ($options) { $params = explode(',', $options); $params = array_map('trim', $params); } else { $params = array(); } // Generate the appropriate HTML using the data from the Diagram and // file objects. $style = ''; $class = 'diagram-content'; $alt = ''; $has_layout = false; foreach ($params as $param) { if (strpos($param, '=') !== false) { list($key, $value) = explode('=', $param, 2); } else { $key = $param; $value = null; } switch ($key) { case 'layout': $has_layout = true; if ($value === 'left') { $class .= ' phabricator-remarkup-embed-layout-left'; } else if ($value === 'right') { $class .= ' phabricator-remarkup-embed-layout-right'; } break; case 'float': $class .= ' phabricator-remarkup-embed-float-left'; break; case 'size': if ($value === 'full') { $style .= 'width: 100%;'; } break; case 'alt': $alt = phutil_escape_html($value); break; } } if ($has_layout == false) { $class .= ' phabricator-remarkup-embed-layout-left'; } $output = phutil_tag( 'div', array( 'class' => 'diagram-container', ), phutil_tag( 'img', array( 'style' => $style, 'class' => $class, 'src' => 'data:image/png;base64,' . $diagram->getBase64Data(), 'alt' => $alt, 'data-sigil' => 'diagram-remarkup-image', 'data-diagram-version' => $diagram->getPHID(), 'data-diagram-id' => $diagram->getDiagramID(), 'title' => 'Double click to edit...' ) ) ); return $output; } + + public function getDocumentation() { + return <<