Markdown Editor preview width only 50px (Angular Wrapper)
See original GitHub issueI know that Angular is officialy not supported, but I don’t think that this is an angular specific problem.
Describe the bug
I’am loading the tui editor with an angular wrapper with previewStyle="vertical".
It is basically working, but the preview on the right has only a width of 50 pixel.
To Reproduce
Steps to reproduce the behavior:
- Install ng-tui-editor in an angular app of your choice
- Import the needed styles in your global styles file:
@import "~tui-editor/dist/tui-editor-contents.css";
@import "~tui-editor/dist/tui-editor.css";
@import "~codemirror/lib/codemirror.css";
- Place
<tui-editor></tui-editor>in any html template - Type in an example text in markdown mode
- See error
Expected behavior
I expect that the preview has a with of 50%.
Screenshots
Desktop (please complete the following information):
- OS: Windows 10 Pro
- Browser: Firefox & Chrome
- Versions: latest versions
Additional context
Maybe something is just missing in the wrapper? Some missing styles maybe? If you want to have a quick look into the wrapper component, here you go. Not much code:
import { Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter, forwardRef, AfterViewInit } from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from "@angular/forms";
import tuiEditor from 'tui-editor';
@Component({
selector: 'tui-editor',
template: `<div #tuiEditor></div>`,
providers: [{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NgTuiEditorComponent),
multi: true
}]
})
export class NgTuiEditorComponent implements ControlValueAccessor, OnInit {
onChange: (_: any) => void = (_: any) => {};
onTouched: () => void = () => {};
private editor!: tuiEditor;
private EditorElement: ElementRef<HTMLDivElement>;
@ViewChild('tuiEditor', { static: true }) set EditorElementSetter(el: ElementRef) {
this.EditorElement = el;
}
@Input('initialEditType') private initialEditType: 'markdown' | 'wysiwyg';
@Input('ngModel') value: string;
@Input('previewStyle') private previewStyle: 'vertical' | 'tab';
@Input('height') private height: string;
@Input('dir') private dir: 'ltr' | 'rtl' = 'ltr';
@Output('change') private change: EventEmitter<NgTuiEditorComponent> = new EventEmitter();
constructor() {}
ngOnInit(): void {
this.editor = new tuiEditor({
el: this.EditorElement.nativeElement,
initialValue: this.value,
initialEditType: this.initialEditType || 'wysiwyg',
previewStyle: this.previewStyle || 'vertical',
height: this.height || '300px',
events: ({
change: ($event) => {
let value = this.getValue();
this.writeValue(value);
this.change.emit(this);
}
} as any)
});
this.EditorElement.nativeElement.querySelector('.tui-editor-contents').setAttribute('dir', this.dir);
}
updateChanges(): void {
this.onChange(this.value);
}
writeValue(value: string): void {
if (value != this.editor.getValue()) {
this.editor.setValue(value);
}
this.value = value;
this.updateChanges();
}
registerOnChange(fn: any): void {
this.onChange = fn;
}
registerOnTouched(fn: any): void {
this.onTouched = fn;
}
public getHTML(): string {
return this.editor.getHtml();
}
public getValue(): string {
return this.editor.getMarkdown();
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (4 by maintainers)
Top Results From Across the Web
Prettier 1.8: Markdown Support
One of Prettier's core features is its ability to wrap code at a specified ... The only verdict is vengeance; a vendetta held...
Read more >Wrap text in <td> tag - html - Stack Overflow
I have tried with style="word-wrap: break-word;" width="15%" . But it is not wrapping the text. Is it mandatory to give it 100% width?...
Read more >Markdown editing with Visual Studio Code
To start, drag a file from VS Code's explorer over your Markdown code and then hold down Shift to start dropping it into...
Read more >HTML and CSS Tutorial - Nanyang Technological University
This is my first web page written in HTML. HTML. HTML uses markup tag to markup a document. Use a source-code editor, which...
Read more >How to Add Border to Image in CSS - W3docs
If you want to increase the width of the frame, add more padding. Example of framing an image with a colored background: <!DOCTYPE...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found


A easy way to fix. rewrite css, with: 100%.
.tui-editor .te-md-splitter { display: none; position: absolute; left: 50%; top: 0; height: 100%; width: 100% !important; border-left: 1px solid #e5e5e5; }Is it possible that
npm i tui-editoris deprecated and everyone should just usenpm i @toast-ui/editor? tui-editor runs on version 1.4.10, but latest version is 2.1.2@seonim-ryu Maybe you either mark the tui-editor package as deprecated or publish the latest version there too. It seems that this bug got solved in @toast-ui/editor package some time ago.