-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f952338
commit ea09878
Showing
15 changed files
with
281 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './schemas'; | ||
export * from './plugins'; | ||
export * from './node-views'; | ||
export * from './components'; |
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/flat-task-list/src/node-views/task-list-item-node-view.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { NodeType } from 'prosemirror-model'; | ||
import { Plugin as PMPlugin } from 'prosemirror-state'; | ||
import { createNode } from '../utils'; | ||
import { EdimFlatTaskListItemAttrs } from '../schemas'; | ||
|
||
export interface EdimTaskListItemNodeViewPluginConfigs { | ||
taskListItemNodeType: NodeType; | ||
} | ||
|
||
export const edimTaskListItemNodeViewPlugins = ( | ||
configs: EdimTaskListItemNodeViewPluginConfigs, | ||
): PMPlugin[] => { | ||
const plugins: PMPlugin[] = [ | ||
new PMPlugin({ | ||
props: { | ||
nodeViews: { | ||
[configs.taskListItemNodeType.name]: (node, view, getPos) => { | ||
const li = createNode(node); | ||
|
||
li.addEventListener('mousedown', (event) => { | ||
const rect = li.getBoundingClientRect(); | ||
const clickX = event.clientX; | ||
const liLeftX = rect.left; | ||
|
||
const paddingLeftValue = li | ||
.computedStyleMap() | ||
.get('padding-left') as CSSUnitValue; | ||
const paddingLeft = paddingLeftValue.value; | ||
|
||
if (clickX > liLeftX + paddingLeft) { | ||
return; | ||
} | ||
|
||
const pos = getPos(); | ||
if (pos === undefined) { | ||
return; | ||
} | ||
|
||
const attrs = node.attrs as EdimFlatTaskListItemAttrs; | ||
const tr = view.state.tr.setNodeMarkup( | ||
pos, | ||
configs.taskListItemNodeType, | ||
{ | ||
...attrs, | ||
checked: !attrs.checked, | ||
}, | ||
); | ||
view.dispatch(tr); | ||
}); | ||
|
||
return { | ||
dom: li, | ||
contentDOM: li, | ||
destroy: () => {}, | ||
}; | ||
}, | ||
}, | ||
}, | ||
}), | ||
]; | ||
return plugins; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.