feat: Code Widget + Markdown Widget Internal Overhaul (#2828)

* wip - upgrade to slate 0.43

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* finish list handling logic

* add plugins directory

* tests wip

* setup testing

* wip

* add selection commands

* finish list testing

* stuff

* add codemirror

* abstract codemirror from slate

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* codemirror mostly working, some bugs

* upgrade to slate 46

* upgrade to slate 47

* wip

* wip

* progress

* wip

* mostly working links with surrounding marks

* wip

* tests passing

* add test

* fix formatting

* update snapshots

* close self closing tag in markdown html output

* wip - commonmark

* hold on commonmark work

* all tests passing

* fix e2e specs

* ignore tests in esm builds

* break/backspace plugins wip

* finish enter/backspace spec

* fix soft break handling

* wip - editor component deletion

* add insertion points

* make insertion points invisible

* fix empty mark nodes output to markdown

* fix pasting

* improve insertion points

* add static bottom insertion point

* improve click handling at insertion points

* restore current table functionality

* add paste support for Slate fragments

* support cut/copy markdown, paste between rich/raw editor

* fix copy paste

* wip - paste/select bug fixing

* fixed known slate issues

* split plugins

* fix editor toggles

* force text cursor in code widget

* wip - reorg plugins

* finish markdown control reorg

* configure plugin types

* quote block adjacent handling with tests

* wip

* finish quote logic and tests

* fix copy paste plugin migration regressions

* fix force insert before node

* fix trailing insertion point

* remove empty headers

* codemirror working properly in markdown widget

* return focus to codemirror on lang select enter

* fix state issues for widgets with local state

* wip - vim working, just need to work out distribution

* add settings pane

* wip - default modes

* fix deps

* add programming language data

* implement linguist langs in code widget

* everything built in

* remove old registration code, fix focus styling

* fix/update linting setup

* fix js lint errors

* remove stylelint from format script

* fix remaining linting errors

* fix reducer test failures

* chore: update commitlint for worktree support

* chore: fix remaining tests

* chore: drop unused monaco plugin

* chore: remove extraneous global styles rendering

* chore: fix failing tests

* fix: tests

* fix: quote/list nesting (tests still broken)

* fix: update quote tests

* chore: bring back code widget test config

* fix: autofocus

* fix: code blocks without the code widget

* fix: code editor component state issues

* fix: error

* fix: add code block test, few fixes

* chore: remove notes

* fix: [wip] update stateful shortcodes on undo/redo

* fix: support code styled links, handle unknown langs

* fix: few fixes

* fix: autofocus on insert, focus on all clicks

* fix: linting

* fix: autofocus

* fix: update code block fixture

* fix: remove unused cypress snapshot plugin

* fix: drop node 8 test, add node 12

* fix: use lodash.flatten instead of Array.flat

* fix: remove console logs
This commit is contained in:
Shawn Erquhart
2019-12-16 12:17:37 -05:00
committed by Erez Rokah
parent be46293f82
commit 18c579d0e9
110 changed files with 12693 additions and 8516 deletions

View File

@ -2,12 +2,15 @@ import { Map, List, fromJS } from 'immutable';
import * as actions from 'Actions/entries';
import reducer from '../entryDraft';
jest.mock('uuid/v4', () => jest.fn(() => '1'));
const initialState = Map({
entry: Map(),
mediaFiles: List(),
fieldsMetaData: Map(),
fieldsErrors: Map(),
hasChanged: false,
key: '',
});
const entry = {
@ -23,7 +26,8 @@ const entry = {
describe('entryDraft reducer', () => {
describe('DRAFT_CREATE_FROM_ENTRY', () => {
it('should create draft from the entry', () => {
expect(reducer(initialState, actions.createDraftFromEntry(fromJS(entry)))).toEqual(
const state = reducer(initialState, actions.createDraftFromEntry(fromJS(entry)));
expect(state).toEqual(
fromJS({
entry: {
...entry,
@ -33,6 +37,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: Map(),
fieldsErrors: Map(),
hasChanged: false,
key: '1',
}),
);
});
@ -40,7 +45,8 @@ describe('entryDraft reducer', () => {
describe('DRAFT_CREATE_EMPTY', () => {
it('should create a new draft ', () => {
expect(reducer(initialState, actions.emptyDraftCreated(fromJS(entry)))).toEqual(
const state = reducer(initialState, actions.emptyDraftCreated(fromJS(entry)));
expect(state).toEqual(
fromJS({
entry: {
...entry,
@ -50,6 +56,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: Map(),
fieldsErrors: Map(),
hasChanged: false,
key: '1',
}),
);
});
@ -127,6 +134,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: {},
fieldsErrors: {},
hasChanged: false,
key: '',
});
});
});
@ -144,6 +152,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: {},
fieldsErrors: {},
hasChanged: false,
key: '',
});
});
});
@ -161,6 +170,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: {},
fieldsErrors: {},
hasChanged: false,
key: '',
});
});
});
@ -181,6 +191,7 @@ describe('entryDraft reducer', () => {
fieldsMetaData: {},
fieldsErrors: {},
hasChanged: true,
key: '1',
});
});
});
@ -201,6 +212,7 @@ describe('entryDraft reducer', () => {
entry,
mediaFiles: [{ id: '1' }],
},
key: '',
});
});
});

View File

@ -1,4 +1,5 @@
import { Map, List, fromJS } from 'immutable';
import uuid from 'uuid/v4';
import {
DRAFT_CREATE_FROM_ENTRY,
DRAFT_CREATE_EMPTY,
@ -30,6 +31,7 @@ const initialState = Map({
fieldsMetaData: Map(),
fieldsErrors: Map(),
hasChanged: false,
key: '',
});
const entryDraftReducer = (state = Map(), action) => {
@ -46,6 +48,7 @@ const entryDraftReducer = (state = Map(), action) => {
state.set('fieldsMetaData', action.payload.metadata || Map());
state.set('fieldsErrors', Map());
state.set('hasChanged', false);
state.set('key', uuid());
});
case DRAFT_CREATE_EMPTY:
// New Entry
@ -56,6 +59,7 @@ const entryDraftReducer = (state = Map(), action) => {
state.set('fieldsMetaData', Map());
state.set('fieldsErrors', Map());
state.set('hasChanged', false);
state.set('key', uuid());
});
case DRAFT_CREATE_FROM_LOCAL_BACKUP:
// Local Backup
@ -69,6 +73,7 @@ const entryDraftReducer = (state = Map(), action) => {
state.set('fieldsMetaData', Map());
state.set('fieldsErrors', Map());
state.set('hasChanged', true);
state.set('key', uuid());
});
case DRAFT_CREATE_DUPLICATE_FROM_ENTRY:
// Duplicate Entry