Skip to content

Editor Abstract Class #2

@ashwinkjoseph

Description

@ashwinkjoseph

Task Description
Set up an abstract class for the editor which should define the methods and the APIs for an editor in TPF learning section's tutorials.
In the context of TPF, an editor should have the following behaviour:

  • Accept an HTML Div Element and mount to it while initializing
  • Accept custom styles when initializing and should also allow for customization after initialization.
  • Should store the content in the editor in memory
  • Should have the option to persist the content of the editor in localStorage
  • Should allow external classes to retrieve the content as a formatted string
  • Should have a method for minimizing
  • Should have a method for closing
  • Accept callback function which will be called with appropriate status when minimizing or closing

Acceptance criteria for task

  • Check that the implementations of the class have a private method named mount
  • Check that the implementations of the class have a public method named style.
  • Check that the implementations of the class have a public method named getContent
  • Check that the implementations of the class have a public method named persistContent
  • Check that the implementations of the class have a public method method minimize
  • Check that the implementations of the class have a public method named close

Additional context
Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.

class PFEditorAbstractClass {
    constructor() {
        if (this.constructor === PFEditorAbstractClass) {
            throw new TypeError('Abstract class "PFEditorAbstractClass" cannot be instantiated directly.');
        }
		
		//abstract method for mounting an Editor into a DOM Elemement must be implemented
		if(!typeof this.mountEditorToDOMElement === 'function'){
			throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
		}

                 if (this.content === undefined) {
                         throw new TypeError('Classes implementing PFEditorAbstractClass must have the content as an attribute')
                 }
		
		//abstract method for storing one or more variables in local storage must be implemented
		if(!this.saveContent === 'function'){
			throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
		}]
		
		//abstract method for retrieving one or more variables from local storage must be implemented
		if(!typeof this. this.getContent === 'function'){
			throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
		}
		
		//abstract method for closing the Editor after necessary cleanup operations must be implemented
		if(!typeof this.closeEditor === 'function'){
			throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
		}
		
		//abstract method for minimizing the Editor after necessary saving operations must be implemented
		if(!typeof this.minimizeEditor === 'function'){
			throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
		}
    }
  }

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions