question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Markdown Editor preview width only 50px (Angular Wrapper)

See original GitHub issue

I 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:

  1. Install ng-tui-editor in an angular app of your choice
  2. 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";
  1. Place <tui-editor></tui-editor> in any html template
  2. Type in an example text in markdown mode
  3. See error

Expected behavior

I expect that the preview has a with of 50%.

Screenshots

ng-tui-editor-bug

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:open
  • Created 3 years ago
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
tadadacommented, Nov 26, 2020

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; }

3reactions
JensUweBcommented, May 29, 2020

Is it possible that npm i tui-editor is deprecated and everyone should just use npm 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found