queenplay-associates / coquill

A real-time collaborative screenplay text editor
https://coquill-e559a.firebaseapp.com/
4 stars 2 forks source link
color delta firebase immutablejs react realtime realtime-collaboration redux screenplay sentiment sentiment-analysis text-editor user-presence-detection writer

Coquill

Coquill is a real-time collaborative text editor for writing screenplays. Based on your selection, the editor will automatically format your text and provide text styling if need be. Once you have created a screenplay, the editor will project colors on the page which map to the context of your text. https://github.com/queenplay-associates/coquill

Created by ❀️ Eleni πŸ’œ Samantha πŸ’– Christina πŸ’™ Guang️ ️

Tech Stacks

React, Redux, Firebase, Immutable.js, Webpack, Babel, React-hot-loader, Sentiment (in progress)

Data Flow

Reducer sample

export const setValue = (value, index, name) => ({
  type: SET_VALUE,
  value,
  componentKey: index,
  name
})
...
const reducer = (state = OrderedMap(), action) => {
                    ...
    case INSERT_AFTER:
        itemsBefore = state.takeUntil(({key}) => key === action.afterKey)
        const after = state.get(action.afterKey)
        itemsAfter = state.skipUntil(({key}) => key === action.afterKey)
                              .delete(action.afterKey)
      return itemsBefore             
        .set(action.afterKey, after) 
        .set(action.actionKey, {   
          type: action.objectType,
          key: action.actionKey,
        })
        .merge(itemsAfter)    
            ...

    case SET_VALUE:
    case CHANGE_TYPE:
      return state.update(action.componentKey, item => itemReducer(item, action))

    default: return state
         }
    }
...

function itemReducer(item = {}, action) {
  const {type} = action
  if (type === SET_VALUE)
    return {...item, value: action.value, name: action.name}
  if (type === CHANGE_TYPE)
    return {...item, type: action.objectType}
  return item
}

Firebase sample

-Screenplays
    -L-Pdurudnr1DSlx08BO
        -actionKey: "-L-Pdurudnr1DSlx08BO"
        -componentKey: "-L-O8hlCEDLV_z3CPTYm" // each unqic action may share same componentKey
        -name: "SJ"
        -type: "SET_VALUE"
        -value: ""One of our biggest challenges was..."
-Users
    -xOedKRr8zoVvKzhgby1xx0 //user's auth id
    -contributedScreenPlays: "Demo Day"
    -displayName: "Spike Jonze"
    -permissions
    -photoURL:

Get started:

git clone git@github.com:queenplay-associates/coquill.git
npm install
npx firebase init
npm start