Issue #2655Opened March 16, 2020by Hsin903210 reactions

[QUESTION] How to editable in innerHTML

Question

hello, I want use blockManager to created component. I had run the dotted line, that's great and I can see this.

this.editor.runCommand('sw-visibility');

then , this is my component code

blockManager.add('row', {
                label: 'choose',
                content:`<div class="chs-row" data-gjs-droppable=".row-cell" >
                    <div class="chs-column" data-gjs-custom-name="choose">
                        <div class="chs-row-cell num" data-gjs-draggable=".row">1</div>
                        <div class="chs-row-cell chs" data-gjs-draggable=".row">
                            <div class="chsBlock">A○</div>
                            <div class="chsBlock">B○</div>
                            <div class="chsBlock">C○</div>
                            <div class="chsBlock">D○</div>
                        </div>
                    </div>
                </div>
                <style>...</style>`              
            });

that's run perfect like this image. I can edit text and see the dotted line in class .chs-row-cell 1

today ,I want add resizable in this component (only this component can resizable ) so, I change code like↓

blockManager.add('row', {
                label: 'choose',
                content:{
                    type: 'text',
                    content:`
                    <div class="chs-row" data-gjs-droppable=".row-cell" >
                      <div class="chs-column" data-gjs-custom-name="choose">
                        <div class="chs-row-cell num" data-gjs-draggable=".row">1</div>
                        <div class="chs-row-cell chs" data-gjs-draggable=".row">
                           <div class="chsBlock">A○</div>
                            <div class="chsBlock">B○</div>
                            <div class="chsBlock">C○</div>
                            <div class="chsBlock">D○</div>
                          </div>
                      </div>
                  </div>
                  <style>...</style>`,
                    resizable:{tc: 1,cl: 1,cr: 1,bc: 1,},
                },                   
            });

resizable is run great ,but component have some problem like Image, I try add type: 'text' so I can edit text but I can't see and can't use dotted line in class .chs-row-cell and .chsBlock

3

I want this component can do something.

  • I can see the dotted line
  • selected can resizable block
  • text can edit

how can I do? Thanks!

Answers (3)

Hsin90321March 18, 20200 reactions

I find the problem is not dotted line ,the problem is innterHTML!!! the innterHtml let my component can't edit.

I want use modal to show input let view change. restart render view the work is perfect. but I still can't edit.

there is my code (leave out model,because there are work great)

blockManager.add('row2', {
  label: "row2",
  content: {
   type:'row2',
    val3,
  },  
}); 
const dc = editor.DomComponents;
const defType = dc.getType('default');
const val3 = `<div class="aa" data-gjs-droppable=".bb" data-gjs-custom-name="AA">
                        <div class="bb" data-gjs-draggable=".aa">456</div>
                            <div class="bb" data-gjs-draggable=".aa">789</div>
                      </div>`;

dc.addType('row2', {
  model: defType.model.extend({
   init() {
    console.log('Local hook: model.init');
   },
 }),
 view:defType.view.extend({
   render() {
     defType.view.prototype.render.apply(this, arguments);
     this.el.innerHTML = this.model.get('val3');      //here!
     return this;
   },
  })
})

1584524335664 like the gif, I cant't edit 456 and 789 in div

I had try type:'text' and editable: true,

blockManager.add('row2', {
 content: {
  type:'text',
 },  
}); 

or

dc.addType('row2', {
 model: defType.model.extend({
  defaults:{
   editable: true,
   attributes: { 
    type: 'text',
   },
  }
})

but there are not working. :(

1584523001546

If I don't use innterHTML, how can I get val3's value and show it? Thanks!!!!

Hsin90321March 19, 20200 reactions

hello, I'm find the answer for editable in #460

const textType = comps.getType('text');

now,the component can edit text. but, still not show dotted line. 1584587780421

artfMarch 20, 20200 reactions

You have posted a lot of questions on the same issue and you should avoid it. Create a live demo with the issue. BTW, in your original post you've made a mistake

...
label: 'choose',
content:{
	type: 'text',
	// `content` in the component definition is a static string
	content: `<div class="chs-row" data-gjs-droppable=".row-cell" >
	// use components instead
	components: `<div class="chs-row" data-gjs-droppable=".row-cell" >

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.