steveathon / bootstrap-wysiwyg

Tiny bootstrap-compatible WYSIWYG rich text editor
MIT License
661 stars 1.71k forks source link

table toolbar? #108

Open mauseq opened 7 years ago

mauseq commented 7 years ago

Hi, is the plugin able to insert and manage tables?

codewithtyler commented 7 years ago

No, we have not implemented anything like that.

icandothat2 commented 6 years ago

I did it like this. Inside of execcommand I put a switch case with the built in code as the default behavior and one of the cases is 'insertCols' which corresponds to a button I created with control to dictate how many columns of what size. This actually implements bootstrap girds not real tables but you could just as easily make tables.

 case 'insertCols':
                           //var numCols = document.getElementById('num_cols');
                           var colWidths = document.getElementsByClassName('colWidthSelector');
                           var row = document.createElement('div');
                           var cols = [];
                           row.className = 'row';
                           for(var x = 0; x < colWidths.length; x++){
                               cols.push( document.createElement('div'));
                               cols[x].className = 'innerCol showBorder  contents col-md-' + colWidths[x].value;
                               cols[x].contentEditable = true;
                               cols[x].style.minHeight = '30px';
                               row.appendChild(cols[x]);
                               row.contentEditable = false;
                           }
                           selectedRange.insertNode(row);

                           break;
steveathon commented 6 years ago

Do you think there is an advantage to bootstrap grids over regular tables? I wonder if the editor will handling pasting data from something like a spreadsheet better if we implement tables?

icandothat2 commented 6 years ago

I don't think there is a general benefit to using grids over tables. I have a site that uses grids and I wanted to stick with that. If you're trying to handle pasting from a spreadsheet I don't know if the browser would be table to tell, maybe IE can, I'm not sure. That's an interesting idea.

On Tue, May 29, 2018 at 6:55 PM, Steve King notifications@github.com wrote:

Do you think there is an advantage to bootstrap grids over regular tables? I wonder if the editor will handling pasting data from something like a spreadsheet better if we implement tables?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/steveathon/bootstrap-wysiwyg/issues/108#issuecomment-393005106, or mute the thread https://github.com/notifications/unsubscribe-auth/APcqjO1znrW_JNzkeCY3b_EVwKClaZJIks5t3fwlgaJpZM4LhiUI .

spreadred commented 6 years ago

While many sites still stick to tables for layout, they are certainly seeing less use in recent years with the advent of Bootstrap grids and I'd imagine even less so once everyone becomes familiar with the awesome CSS Grids! The more complicated your table layout, the more difficult it becomes to manage/maintain your layout with traditional table elements. I don't suppose it really matters much which you choose in this case though...