Skip to content

Commit

Permalink
Merge pull request #33 from juliankrispel/model-changes
Browse files Browse the repository at this point in the history
[WChange model to allow Fragments
  • Loading branch information
juliankrispel authored May 20, 2020
2 parents 2094e8d + 64e6dd5 commit 09bd342
Show file tree
Hide file tree
Showing 61 changed files with 2,896 additions and 3,811 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
run: |
cd core && yarn link && cd ..
cd react
yarn
yarn link @zettel/core
yarn
yarn test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Zettel

## [Unreleased]

### Added
- Added Fragment Model. Fragments are similar to Blocks, they can either contain text or other fragments. They can also contain metadata which makes them useful for things such as mentions. Fragments can cross block boundaries. If `[ ]` is a block boundary and `< >` a fragment boundary we can do things like: `[First <Block][Second> Block]`.
- Soft newlines are now supported and working correctly (tested in markdown example with codeblocks)

## [0.0.21] - 2020-05-18

### Changed
Expand Down
9 changes: 3 additions & 6 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"author": "Julian Krispel",
"license": "MIT",
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test": "../node_modules/.bin/jest .",
"test:watch": "../node_modules/.bin/jest . --watch",
"build": "tsc",
"start": "tsc -w",
"prepare": "tsc"
Expand All @@ -17,9 +17,6 @@
"dist"
],
"devDependencies": {
"@types/dom-inputevent": "^1.0.4",
"@types/jest": "^24.0.19",
"ts-jest": "^24.1.0",
"jest": "^24.9.0"
"@types/dom-inputevent": "^1.0.4"
}
}
12 changes: 6 additions & 6 deletions core/src/EditorState/EditorState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ export default class EditorState {
const end = _end + 1
const selectedValue = this.list.value.slice(start, end)
const hasStyle = selectedValue.every(char =>
char.type != null ||
char.styles.includes(style)
'type' in char ||
(char.styles || []).includes(style)
)

const updatedValue = selectedValue.map(char => {
const newChar = { ...char }
if (newChar.type == null) {
if ('char' in newChar) {
if (hasStyle) {
newChar.styles = newChar.styles.filter(st => st !== style)
} else if (!newChar.styles.includes(style)) {
newChar.styles = newChar.styles.concat([style])
newChar.styles = (newChar.styles || []).filter(st => st !== style)
} else if (!(newChar.styles || []).includes(style)) {
newChar.styles = (newChar.styles || []).concat([style])
}
}

Expand Down
Loading

0 comments on commit 09bd342

Please sign in to comment.