Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apostrophe cms 向撇号richt文本添加字段_Apostrophe Cms - Fatal编程技术网

Apostrophe cms 向撇号richt文本添加字段

Apostrophe cms 向撇号richt文本添加字段,apostrophe-cms,Apostrophe Cms,我想让撇号富文本小部件可配置,允许设置文本列的数量。(然后,这个数字将转换为一个CSS类,这是最简单的部分。) 如何将字段添加到富文本小部件中?下面将显示编辑富文本按钮,但当我单击它时,什么也没有发生 // my-app/lib/modules/apostrophe-rich-text-widgets/index.js const _ = require('lodash'); module.exports = { beforeConstruct: function(self,optio

我想让
撇号富文本小部件
可配置,允许设置文本列的数量。(然后,这个数字将转换为一个CSS类,这是最简单的部分。)

如何将字段添加到富文本小部件中?下面将显示编辑富文本按钮,但当我单击它时,什么也没有发生

// my-app/lib/modules/apostrophe-rich-text-widgets/index.js
const _ = require('lodash');

module.exports = {
    beforeConstruct: function(self,options) {

        //options.contextualOnly = !_.isUndefined(options.contextualOnly) ? options.contextualOnly : false;
        options.contextualOnly = false;

        options.addFields = [
            {
                name: 'nr_columns',
                type: 'integer',
                min: 1,
                max: 3,
                label: 'Number of Columns'
            }
        ].concat(options.addFields || []);
    }
};
更新

因此,我实现了一个包装器小部件,它允许我将列数配置为整数,并将
撇号富文本
小部件添加为单例

// lib/modules/my-wrapper/index.js
module.exports = {                                                
    extend: 'apostrophe-widgets',                                 
    label: 'Multi-column Text',                                   
    skipInitialModal: true,                                     
    addFields: [                                                  
        {                                                         
            name: 'nr_columns',                                   
            label: 'Nr. of Columns',                              
            type: 'integer',                                      
            required: true,                                       
            min: 1,                                               
            max: 3                                                
        },                                                        
        {                                                         
            name: 'text',                                         
            label: 'Text',                                        
            type: 'singleton',                                    
            widgetType: 'apostrophe-rich-text',                   
            contextual: true                                      
        }                                                         
    ]                                                             
};
当我将包装器小部件添加到页面时,看不到富文本编辑器。在
views/widget.html
中需要什么来实现这一点

更新2

这是我的
视图/widget.html
,但我根本不确定里面应该有什么。(编辑:将下面的
widget.content
替换为
data.widget.content
-仍然存在相同的问题。)

我的
index.js

module.exports = {
    extend: 'apostrophe-widgets',
    label: 'Multi-column Text',
    //skipInitialModal: true,
    addFields: [
        {
            name: 'nr_columns',
            label: 'Nr. of Columns',
            type: 'integer',
            required: true,
            min: 1,
            max: 3
        },
        {
            name: 'text',
            contextualOnly: true,
            type: 'singleton',
            widgetType: 'apostrophe-rich-text'
        }
    ]
};
将小部件添加到页面后看到的内容:


为了获得与撇号的普通撇号富文本小部件相同的效果,您实际上需要将该单例添加到小部件的模板中,如

<div class="some-wrapper">
   {{ apos.singleton(data.widget, 'RICH_TEXT_WIDGET_SCHEMA_NAME', 'apostrophe-rich-text', {...RICHTEXT_OPTIONS_HERE}) }}
</div>

{apos.singleton(data.widget,'RICH_TEXT_widget_SCHEMA_NAME','撇号RICHTEXT',{…RICHTEXT_OPTIONS_HERE}}}

富文本小部件在小部件扩展的正常边界之外运行,更难覆盖。相反,我将创建一个包装器小部件,其模式为富文本单例和列计数整数。如果需要,可以使小部件
skipInitialModal:true
和RT singleton
上下文:true
在放置时表现得像普通的富文本小部件一样。然后像您所希望的那样实现列。不确定这是一个令人满意的答案。谢谢,我会试试的!请发布您的包装器小部件的
视图/widget.html
Done@stuartromanek。添加单例时,
撇号富文本
小部件似乎没有实际添加;相反,会出现一个按钮,用于添加富文本区域。这可能就是为什么它是空的原因。我如何告诉撇号添加一个
撇号富文本
小部件,而不是添加一个小部件的按钮?因此我从
index.js
中删除了
单体
,我的
视图/widget.html
包含
{apos.singleton(data.widget,'multi-column text',撇号富文本',{toolbar:['Bold','Italic'],上下文:true}}}}
我现在可以看到多列,但仍然有一个按钮说添加富文本,而不是实际的小部件。我错过了什么?不太清楚你的意思。“添加富文本”是富文本小部件的空状态。您需要在小部件的
index.js
中保留singleton字段,因为撇号将用于各种清理操作<代码>上下文:不会识别小部件选项中的true,这只是模态编辑器的标志。您的内容正在保存吗?很抱歉造成混乱。我用
views/widget.html
index.js
和屏幕截图再次更新了原始问题。这看起来是正确的。您仍然对预期会发生什么感到困惑。啊,您希望自动初始化富格文本编辑器,就像您将独立富格文本小部件放在页面上时所做的那样。我认为简单的答案是没有现成的方法可以做到这一点,但我可以想象它是一个小公关撇号核心和富文本小部件的选项。
module.exports = {
    extend: 'apostrophe-widgets',
    label: 'Multi-column Text',
    //skipInitialModal: true,
    addFields: [
        {
            name: 'nr_columns',
            label: 'Nr. of Columns',
            type: 'integer',
            required: true,
            min: 1,
            max: 3
        },
        {
            name: 'text',
            contextualOnly: true,
            type: 'singleton',
            widgetType: 'apostrophe-rich-text'
        }
    ]
};
<div class="some-wrapper">
   {{ apos.singleton(data.widget, 'RICH_TEXT_WIDGET_SCHEMA_NAME', 'apostrophe-rich-text', {...RICHTEXT_OPTIONS_HERE}) }}
</div>