1. #11
    Ext JS Premium Member prophet's Avatar
    Join Date
    Mar 2007
    Location
    Greenwich, CT
    Posts
    187
    Vote Rating
    0
    prophet is on a distinguished road

      0  

    Default


    Nice additions, Stju!
    ...Dont't getValue and setValue already exist though?
    Brad Baumann

  2. #12
    Sencha User
    Join Date
    Nov 2009
    Location
    Poland
    Posts
    84
    Vote Rating
    2
    saprot is on a distinguished road

      0  

    Default


    it works with the latest CodeMirror git snapshot

  3. #13
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    Quote Originally Posted by Stju View Post
    Had today time to work around this component..
    so here are few additional methods:
    Code:
        getValue: function() {
            return this.codeMirrorEditor.getCode();
        },
    
        setValue: function(text) {
            this.codeMirrorEditor.setCode(text);
        },
    
        setValueAtCursor: function(text) {
            var cursorPosition = this.codeMirrorEditor.cursorPosition();
            var handleForCursorLine = this.codeMirrorEditor.cursorLine();
            this.codeMirrorEditor.insertIntoLine(handleForCursorLine, cursorPosition.character, text);
        }
    It doesn't work.. Gives an error like this : "this.editor is undefined".. Can someone help me? (I mean setValue and getValue functions)

  4. #14
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    288
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    It works, it has been tested with different CodeMirror versions!
    As You didn't post the line and file where that error appears it's almost impossible to help, although it looks like You have not included codemirror file before extjs code..

  5. #15
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    Quote Originally Posted by Stju View Post
    It works, it has been tested with different CodeMirror versions!
    As You didn't post the line and file where that error appears it's almost impossible to help, although it looks like You have not included codemirror file before extjs code..
    Error happened at this line:
    Code:
    setValue: function(text) {
        this.codeMirrorEditor.setCode(text);
    }
    And here's the list of my includes:
    Code:
      <script src="./script/jsBeautify/beautify.js"></script>
    	<script src="./script/lib/ext/ux/codemirror/CodeMirror-0.63/js/codemirror.js"></script>
    	<script src="./script/lib/ext/ux/codemirror/Ext.ux.panel.CodeMirror.js"></script>
    	<script src="./script/lib/ext/ux/codemirror/jslint.js"></script>
    	
    	<!-- Source File -->
    	<script type="text/javascript" src="./script/homepage.js"></script>

  6. #16
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    288
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    1. You are using VERY old version of editor.. I strongly recommend using latest one, since the some latest versions fixes numerous Webkit browser related issues!
    2.Editor must be rendered before You can set the its value!
    Excerpt from my code, maybe it will help You:
    Code:
    this.snipCodePanel = new Ext.ux.panel.CodeMirror({
            height:240,
            title:'Code view',
            autoScroll:true,
            bodyStyle:'background-color:white',
            //codemirror stuff
            listeners: {
                render: function(){
                    this.doLayout();
                }
            },
            //sourceCode: '',
            parser: 'php',
            codeMirror:{
                lineNumbers:false
            },
    ...
        });

  7. #17
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    OK, thanks a lot for your helps Stju. It works now, I thought the attached file is recent; but the recent version is 0.91. (Release date : 11/11/2010)

  8. #18
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    288
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    Welcome!
    Nice to hear!

  9. #19
    Sencha User Zerogiven's Avatar
    Join Date
    Mar 2010
    Location
    Linz, Austria
    Posts
    29
    Vote Rating
    1
    Zerogiven is on a distinguished road

      0  

    Default


    hi,

    first, thanks for your panel it works a bit better for me than the other codemirror ux. I also made two functions for hide/show codemirror and hide/show the textarea with the same value.

    Maybe someone else can need it too

    PHP Code:
    codeMirrorHiddenfalse//just a public config
    hideCodeMirror: function () {
        var 
    iframeEl Ext.select('div#'+this.id ' > div > div > .CodeMirror-wrapping'true);
        var 
    textareaEl Ext.select('div#'+this.id ' > div > div > textarea'true);

        
    this.items.itemAt(0).setValuethis.getValue() );

        
    iframeEl.setVisible(false);
        
    textareaEl.setVisible(true);
        
    textareaEl.removeClass('x-hide-display');

        
    this.items.itemAt(0).setWidth("100%");
        
    this.items.itemAt(0).setHeight("100%");

        
    this.codeMirrorHidden true;
    },
    showCodeMirror: function () {
        var 
    iframeEl Ext.select('div#'+this.id ' > div > div > .CodeMirror-wrapping'true);
        var 
    textareaEl Ext.select('div#'+this.id ' > div > div >textarea'true);

        
    this.setValuethis.items.itemAt(0).getValue() );

        
    textareaEl.addClass('x-hide-display');
        
    textareaEl.setVisible(false);
        
    iframeEl.setVisible(true);

        
    this.codeMirrorHidden false;

    At least i inserted the following code insert the triggerCodeEditor function right after initializing codemirror (new CodeMirror...):

    PHP Code:
    var iframeEl Ext.select('div#'+this.id ' > div > div > .CodeMirror-wrapping'true);
    var 
    textareaEl Ext.select('div#'+this.id ' > div > div > textarea'true);

    textareaEl.setVisibilityMode(Ext.Element.DISPLAY);
    iframeEl.setVisibilityMode(Ext.Element.DISPLAY);

    if (
    this.codeMirrorHiddenthis.hideCodeMirror(); 
    greetz
    Chris

  10. #20
    Ext User
    Join Date
    Dec 2010
    Posts
    1
    Vote Rating
    0
    bugu1986 is on a distinguished road

      0  

    Default nice work

    nice work


    nice work