mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-03 23:14:13 +00:00 
			
		
		
		
	
							parent
							
								
									2c5162671c
								
							
						
					
					
						commit
						f3155ea180
					
				
					 5 changed files with 44 additions and 1 deletions
				
			
		| 
						 | 
					@ -111,6 +111,14 @@ export default Vue.component('misskey-flavored-markdown', {
 | 
				
			||||||
					}, genEl(token.children));
 | 
										}, genEl(token.children));
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									case 'center': {
 | 
				
			||||||
 | 
										return [createElement('div', {
 | 
				
			||||||
 | 
											attrs: {
 | 
				
			||||||
 | 
												style: 'text-align:center;'
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}, genEl(token.children))];
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				case 'motion': {
 | 
									case 'motion': {
 | 
				
			||||||
					motionCount++;
 | 
										motionCount++;
 | 
				
			||||||
					const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5;
 | 
										const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,6 +45,12 @@ export default (tokens: Node[], mentionedRemoteUsers: INote['mentionedRemoteUser
 | 
				
			||||||
			return pre;
 | 
								return pre;
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							center(token) {
 | 
				
			||||||
 | 
								const el = doc.createElement('div');
 | 
				
			||||||
 | 
								dive(token.children).forEach(child => el.appendChild(child));
 | 
				
			||||||
 | 
								return el;
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		emoji(token) {
 | 
							emoji(token) {
 | 
				
			||||||
			return doc.createTextNode(token.props.emoji ? token.props.emoji : `:${token.props.name}:`);
 | 
								return doc.createTextNode(token.props.emoji ? token.props.emoji : `:${token.props.name}:`);
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ export default (source: string): Node[] => {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function isBlockNode(node: Node): boolean {
 | 
						function isBlockNode(node: Node): boolean {
 | 
				
			||||||
		return ['blockCode', 'quote', 'title'].includes(node.name);
 | 
							return ['blockCode', 'center', 'quote', 'title'].includes(node.name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +73,7 @@ const mfm = P.createLanguage({
 | 
				
			||||||
		r.math,
 | 
							r.math,
 | 
				
			||||||
		r.search,
 | 
							r.search,
 | 
				
			||||||
		r.title,
 | 
							r.title,
 | 
				
			||||||
 | 
							r.center,
 | 
				
			||||||
		r.text
 | 
							r.text
 | 
				
			||||||
	).atLeast(1),
 | 
						).atLeast(1),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,6 +114,23 @@ const mfm = P.createLanguage({
 | 
				
			||||||
		).atLeast(1).tryParse(x))),
 | 
							).atLeast(1).tryParse(x))),
 | 
				
			||||||
	//#endregion
 | 
						//#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//#region Center
 | 
				
			||||||
 | 
						center: r =>
 | 
				
			||||||
 | 
							P.regexp(/<center>([\s\S]+?)<\/center>/, 1)
 | 
				
			||||||
 | 
							.map(x => makeNodeWithChildren('center', P.alt(
 | 
				
			||||||
 | 
								r.big,
 | 
				
			||||||
 | 
								r.bold,
 | 
				
			||||||
 | 
								r.motion,
 | 
				
			||||||
 | 
								r.mention,
 | 
				
			||||||
 | 
								r.hashtag,
 | 
				
			||||||
 | 
								r.emoji,
 | 
				
			||||||
 | 
								r.math,
 | 
				
			||||||
 | 
								r.url,
 | 
				
			||||||
 | 
								r.link,
 | 
				
			||||||
 | 
								r.text
 | 
				
			||||||
 | 
							).atLeast(1).tryParse(x))),
 | 
				
			||||||
 | 
						//#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//#region Emoji
 | 
						//#region Emoji
 | 
				
			||||||
	emoji: r =>
 | 
						emoji: r =>
 | 
				
			||||||
		P.alt(
 | 
							P.alt(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								test/mfm.ts
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								test/mfm.ts
									
										
									
									
									
								
							| 
						 | 
					@ -641,6 +641,17 @@ describe('Text', () => {
 | 
				
			||||||
				], tokens);
 | 
									], tokens);
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							describe('center', () => {
 | 
				
			||||||
 | 
								it('simple', () => {
 | 
				
			||||||
 | 
									const tokens = analyze('<center>foo</center>');
 | 
				
			||||||
 | 
									assert.deepEqual([
 | 
				
			||||||
 | 
										nodeWithChildren('center', [
 | 
				
			||||||
 | 
											text('foo')
 | 
				
			||||||
 | 
										]),
 | 
				
			||||||
 | 
									], tokens);
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	describe('toHtml', () => {
 | 
						describe('toHtml', () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue