(inserts: string[], removes: string[], records)
| 2778 | }; |
| 2779 | |
| 2780 | updateActions(inserts: string[], removes: string[], records) { |
| 2781 | this.editor.cm.operation(() => { |
| 2782 | for(let recordId of removes) { |
| 2783 | let action = this.activeActions[recordId]; |
| 2784 | if(!action) return; |
| 2785 | let run = this.actions.remove[action.tag]; |
| 2786 | //console.log("STOP", action.tag, recordId, action, !!run); |
| 2787 | if(run) run(action); |
| 2788 | delete this.activeActions[recordId]; |
| 2789 | } |
| 2790 | |
| 2791 | for(let recordId of inserts) { |
| 2792 | let record = records[recordId]; |
| 2793 | let bounds:Range|undefined; |
| 2794 | if(record.within) { |
| 2795 | let span = this.editor.getSpanBySourceId(record.within[0]); |
| 2796 | if(span) bounds = span.find(); |
| 2797 | } |
| 2798 | |
| 2799 | let action:any = {bounds}; |
| 2800 | for(let tag of record.tag) { |
| 2801 | if(tag in this.actions.insert || tag in this.actions.remove) { |
| 2802 | action.tag = tag; |
| 2803 | break; |
| 2804 | } |
| 2805 | } |
| 2806 | if(!action.tag) continue; |
| 2807 | |
| 2808 | for(let attr in record) { |
| 2809 | if(!action[attr]) action[attr] = record[attr]; |
| 2810 | } |
| 2811 | this.activeActions[recordId] = action; |
| 2812 | |
| 2813 | let run = this.actions.insert[action.tag]; |
| 2814 | //console.log("START", action.tag, recordId, action, !!run); |
| 2815 | if(!run) console.warn(`Unable to run unknown action type '${action.tag}'`, recordId, record); |
| 2816 | else run(action, recordId); |
| 2817 | } |
| 2818 | }); |
| 2819 | } |
| 2820 | |
| 2821 | //------------------------------------------------------- |
| 2822 | // Views |
no test coverage detected