@@ -13,6 +13,7 @@ export const SuggestionAddMark = Mark.create({
1313 addAttributes ( ) {
1414 return {
1515 id : { default : null , validate : "number" } , // note: validate is supported in prosemirror but not in tiptap, so this doesn't actually work (considered not critical)
16+ "user-color" : { default : null , validate : "string" } ,
1617 } ;
1718 } ,
1819 extendMarkSchema ( extension ) {
@@ -28,8 +29,13 @@ export const SuggestionAddMark = Mark.create({
2829 "ins" ,
2930 {
3031 "data-id" : String ( mark . attrs [ "id" ] ) ,
32+ "data-user-color" : String ( mark . attrs [ "user-color" ] ) ,
3133 "data-inline" : String ( inline ) ,
32- ...( ! inline && { style : "display: contents" } ) , // changed to "contents" to make this work for table rows
34+ style :
35+ ( inline ? "" : "display: contents" ) +
36+ ( "user-color" in mark . attrs
37+ ? `; --user-color: ${ mark . attrs [ "user-color" ] } `
38+ : "" ) , // changed to "contents" to make this work for table rows
3339 } ,
3440 0 ,
3541 ] ;
@@ -43,6 +49,7 @@ export const SuggestionAddMark = Mark.create({
4349 }
4450 return {
4551 id : parseInt ( node . dataset [ "id" ] , 10 ) ,
52+ userColor : node . dataset [ "userColor" ] ,
4653 } ;
4754 } ,
4855 } ,
@@ -58,6 +65,7 @@ export const SuggestionDeleteMark = Mark.create({
5865 addAttributes ( ) {
5966 return {
6067 id : { default : null , validate : "number" } , // note: validate is supported in prosemirror but not in tiptap
68+ "user-color" : { default : null , validate : "string" } ,
6169 } ;
6270 } ,
6371 extendMarkSchema ( extension ) {
@@ -76,8 +84,13 @@ export const SuggestionDeleteMark = Mark.create({
7684 "del" ,
7785 {
7886 "data-id" : String ( mark . attrs [ "id" ] ) ,
87+ "data-user-color" : String ( mark . attrs [ "user-color" ] ) ,
7988 "data-inline" : String ( inline ) ,
80- ...( ! inline && { style : "display: contents" } ) , // changed to "contents" to make this work for table rows
89+ style :
90+ ( inline ? "" : "display: contents" ) +
91+ ( "user-color" in mark . attrs
92+ ? `; --user-color: ${ mark . attrs [ "user-color" ] } `
93+ : "" ) , // changed to "contents" to make this work for table rows
8194 } ,
8295 0 ,
8396 ] ;
@@ -91,6 +104,7 @@ export const SuggestionDeleteMark = Mark.create({
91104 }
92105 return {
93106 id : parseInt ( node . dataset [ "id" ] , 10 ) ,
107+ userColor : node . dataset [ "userColor" ] ,
94108 } ;
95109 } ,
96110 } ,
@@ -107,6 +121,7 @@ export const SuggestionModificationMark = Mark.create({
107121 // note: validate is supported in prosemirror but not in tiptap
108122 return {
109123 id : { default : null , validate : "number" } ,
124+ "user-color" : { default : null , validate : "string" } ,
110125 type : { validate : "string" } ,
111126 attrName : { default : null , validate : "string|null" } ,
112127 previousValue : { default : null } ,
@@ -133,10 +148,15 @@ export const SuggestionModificationMark = Mark.create({
133148 {
134149 "data-type" : "modification" ,
135150 "data-id" : String ( mark . attrs [ "id" ] ) ,
151+ "data-user-color" : String ( mark . attrs [ "user-color" ] ) ,
136152 "data-mod-type" : mark . attrs [ "type" ] as string ,
137153 "data-mod-prev-val" : JSON . stringify ( mark . attrs [ "previousValue" ] ) ,
138154 // TODO: Try to serialize marks with toJSON?
139155 "data-mod-new-val" : JSON . stringify ( mark . attrs [ "newValue" ] ) ,
156+ style :
157+ "user-color" in mark . attrs
158+ ? ` --user-color: ${ mark . attrs [ "user-color" ] } `
159+ : "" , // changed to "contents" to make this work for table rows
140160 } ,
141161 0 ,
142162 ] ;
@@ -150,6 +170,7 @@ export const SuggestionModificationMark = Mark.create({
150170 }
151171 return {
152172 id : parseInt ( node . dataset [ "id" ] , 10 ) ,
173+ userColor : node . dataset [ "userColor" ] ,
153174 type : node . dataset [ "modType" ] ,
154175 previousValue : node . dataset [ "modPrevVal" ] ,
155176 newValue : node . dataset [ "modNewVal" ] ,
0 commit comments