Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e0409338
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e0409338
编写于
6月 05, 2018
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
We are leveling up the text_area, not the text_field, so match names
上级
73573464
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
8 deletion
+8
-8
README.md
README.md
+2
-2
app/helpers/action_text/tag_helper.rb
app/helpers/action_text/tag_helper.rb
+5
-5
test/dummy/app/views/messages/_form.html.erb
test/dummy/app/views/messages/_form.html.erb
+1
-1
未找到文件。
README.md
浏览文件 @
e0409338
...
...
@@ -41,7 +41,7 @@ Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.
end
```
1.
Replace form
`text_area`
s with
`rich_text_
field
`
s:
1.
Replace form
`text_area`
s with
`rich_text_
area
`
s:
```erb
<%# app/views/messages/_form.html.erb %>
...
...
@@ -49,7 +49,7 @@ Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.
…
<div class="field">
<%= form.label :content %>
<%= form.rich_text_
field
:content %>
<%= form.rich_text_
area
:content %>
</div>
…
<% end %>
...
...
app/helpers/action_text/tag_helper.rb
浏览文件 @
e0409338
...
...
@@ -2,7 +2,7 @@ module ActionText
module
TagHelper
cattr_accessor
(
:id
,
instance_accessor:
false
)
{
0
}
def
rich_text_
field
_tag
(
name
,
value
=
nil
,
options
=
{})
def
rich_text_
area
_tag
(
name
,
value
=
nil
,
options
=
{})
options
=
options
.
symbolize_keys
options
[
:input
]
||=
"trix_input_
#{
ActionText
::
TagHelper
.
id
+=
1
}
"
...
...
@@ -26,7 +26,7 @@ def render
options
=
@options
.
stringify_keys
add_default_name_and_id
(
options
)
options
[
"input"
]
||=
dom_id
(
object
,
[
options
[
"id"
],
:trix_input
].
compact
.
join
(
"_"
))
@template_object
.
rich_text_
field
_tag
(
options
.
delete
(
"name"
),
editable_value
,
options
)
@template_object
.
rich_text_
area
_tag
(
options
.
delete
(
"name"
),
editable_value
,
options
)
end
def
editable_value
...
...
@@ -35,14 +35,14 @@ def editable_value
end
module
FormHelper
def
rich_text_
field
(
object_name
,
method
,
options
=
{})
def
rich_text_
area
(
object_name
,
method
,
options
=
{})
Tags
::
ActionText
.
new
(
object_name
,
method
,
self
,
options
).
render
end
end
class
FormBuilder
def
rich_text_
field
(
method
,
options
=
{})
@template
.
rich_text_
field
(
@object_name
,
method
,
objectify_options
(
options
))
def
rich_text_
area
(
method
,
options
=
{})
@template
.
rich_text_
area
(
@object_name
,
method
,
objectify_options
(
options
))
end
end
end
test/dummy/app/views/messages/_form.html.erb
浏览文件 @
e0409338
...
...
@@ -18,7 +18,7 @@
<div
class=
"field"
>
<%=
form
.
label
:content
%>
<%=
form
.
rich_text_
field
:content
,
class:
"trix-content"
%>
<%=
form
.
rich_text_
area
:content
,
class:
"trix-content"
%>
</div>
<div
class=
"actions"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录