nnhubbard / ZSSRichTextEditor

A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view
MIT License
3.78k stars 585 forks source link

Add content insets at webview's scrollview #144

Open purplepeng opened 8 years ago

purplepeng commented 8 years ago

I want to add a subview at the top of edit view as the following image , wechat_1474302988

so I add a subview and set the scrollview's contentInset. In the ZSSRichTextEditor.m, I add the following code self.editorView.scrollView.contentInset = UIEdgeInsetsMake(108, 0, 0, 0);. How should i change the function in the ZSSRichTextEditor.js? Thank you very much.

zss_editor.calculateEditorHeightWithCaretPosition = function() {

    var padding = 50;
    var c = zss_editor.getCaretYPosition();
    var e = document.getElementById('zss_editor_content');

    var editor = $('#zss_editor_content');

    var offsetY = window.document.body.scrollTop;
    var height = zss_editor.contentHeight;

    var newPos = window.pageYOffset;

    if (c < offsetY) {
        newPos = c;
    } else if (c > (offsetY + height - padding)) {
        var newPos = c - height + padding - 18;
    }

    window.scrollTo(0, newPos);
}