Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it support edit with keyboard same way in editor.js ? #22

Open
ujeshpatel opened this issue Jul 20, 2020 · 6 comments
Open

Is it support edit with keyboard same way in editor.js ? #22

ujeshpatel opened this issue Jul 20, 2020 · 6 comments

Comments

@ujeshpatel
Copy link

Have a question regarding functionality.

I download code and run it with Xcode 11.4, I am seeing editor with sample text in VIEW mode only. is there any way enable edit also with the same editor.

Thanks.

@ivanglushko
Copy link
Collaborator

Hello, thanks for your question.

For now you get out of the box only VIEW mode Functionality.
But there's a possibility to create such behaviour using custom blocks.
We might implement READ and WRITE functionality soon.

@ujeshpatel
Copy link
Author

Thanks for your reply.

Yes, will check custom blocks and try to achieve a goal. meanwhile, we will wait for your update. thank you so much

@hamid512
Copy link

@ivanglushko what is i have custom blocks(from plugins) will it work on ios or only the default stuff from ios

@Upstarts
Copy link
Owner

Upstarts commented Dec 20, 2020

@ivanglushko what is i have custom blocks(from plugins) will it work on ios or only the default stuff from ios

Hey, custom blocks can support any block type regardless of whether it is from existing plugin or it's your own internally designed block.

All you need is to setup the block type, implement data model for it and a view. Here is a short guide:

enum MyCustomBlockType: String, EJAbstractBlockType {
    case myBlockFromAnyPlugin
}

struct MyBlockContentModel: EJAbstractBlockContent {
    // Conform to protocol here. 

    // Unless your block contains a list of items (like a `list`) you want number of items to be 1.
    var numberOfItems: Int { return 1 }

    /// Return your decodable model for an item to be rendered.
    /// If the block you're dealing with contains a list of some items (like `list`), return the one on a corresponding index.
    /// If your block has only one item (like `link`), return that item.
    func getItem(atIndex index: Int) -> EJAbstractBlockContentItem? {
        //
    }
}

Register is somewhere on app launch like this:

let myCustomBlock = EJCustomBlock(type: MyCustomBlockType.myBlockFromAnyPlugin, 
                                                                 contentClass: MyBlockContentModel.self)
EJKit.shared.register(customBlock: myCustomBlock)

In order to render that block create a view which is configurable with your item model type EJAbstractBlockContentItem.
Then you may use provided renderers to pass model items to your view or do it in your own way.

// Assuming there is an only item to be rendered in the block
// Get it, downcast and feed the view
if let blockContentItem = block.getItem(atIndex: 0) as? MyBlockContentModelItem {
    // myView is some view that you designed for that block
    myView.configure(with: blockContentItem)
}

@vijaycoderkube
Copy link

Thanks for your reply.

Yes, will check custom blocks and try to achieve a goal. meanwhile, we will wait for your update. thank you so much

Any update?

@PopovVadim
Copy link
Collaborator

Thanks for your reply.
Yes, will check custom blocks and try to achieve a goal. meanwhile, we will wait for your update. thank you so much

Any update?

No plans to add editing mode for now. Everybody's welcome to contribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants