浏览代码

MdRender 添加 mode

visuddhinanda 3 年之前
父节点
当前提交
879bc31039
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app/Http/Resources/SentResource.php

+ 6 - 1
app/Http/Resources/SentResource.php

@@ -20,10 +20,15 @@ class SentResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $channel = ChannelApi::getById($this->channel_uid);
         $channel = ChannelApi::getById($this->channel_uid);
+        if($request->get('mode','read')==="read"){
+            $mode = 'read';
+        }else{
+            $mode = 'edit';
+        }
         $data = [
         $data = [
                 "id" => $this->uid,
                 "id" => $this->uid,
                 "content"=>$this->content,
                 "content"=>$this->content,
-                "html"=> MdRender::render($this->content,$this->channel_uid),
+                "html"=> MdRender::render($this->content,$this->channel_uid,null,$mode,$channel['type']),
                 "book"=> $this->book_id,
                 "book"=> $this->book_id,
                 "paragraph"=> $this->paragraph,
                 "paragraph"=> $this->paragraph,
                 "word_start"=> $this->word_start,
                 "word_start"=> $this->word_start,