@@ -14,21 +14,22 @@ export function buildSimpleEmbedsViewPlugin(plugin: SimpleEmbedsPlugin) {
1414 class EmbedWidget extends WidgetType {
1515 constructor (
1616 readonly link : string ,
17+ readonly fullWidth : boolean ,
1718 readonly embedSource : EmbedSource ,
1819 readonly plugin : SimpleEmbedsPlugin ,
1920 ) {
2021 super ( ) ;
2122 }
2223
2324 eq ( other : EmbedWidget ) {
24- return other . link === this . link ;
25+ return other . link === this . link && other . fullWidth === this . fullWidth ;
2526 }
2627
2728 toDOM ( ) {
2829 const embed = this . plugin . createEmbed (
2930 this . embedSource ,
3031 this . link ,
31- false ,
32+ this . fullWidth ,
3233 ) ;
3334 return embed ;
3435 }
@@ -96,11 +97,15 @@ export function buildSimpleEmbedsViewPlugin(plugin: SimpleEmbedsPlugin) {
9697 return plugin . settings [ source . enabledKey ] &&
9798 source . regex . test ( line . text ) ;
9899 } ) ;
99- if ( embedSource ) {
100+ const replaceWithEmbed = plugin . shouldReplaceWithEmbed ( mdLink ) ;
101+ const fullWidth = mdLink . includes ( "|fullwidth" ) ;
102+ this . hideOptions ( mdLink , startOfLine , builder ) ;
103+ if ( embedSource && replaceWithEmbed ) {
100104 const link = line . text . match ( embedSource . regex ) . first ( ) ;
101105 const deco = Decoration . replace ( {
102106 widget : new EmbedWidget (
103107 link ,
108+ fullWidth ,
104109 embedSource ,
105110 plugin ,
106111 ) ,
@@ -121,6 +126,22 @@ export function buildSimpleEmbedsViewPlugin(plugin: SimpleEmbedsPlugin) {
121126
122127 return builder . finish ( ) ;
123128 }
129+
130+ hideOptions (
131+ text : string ,
132+ startOfLine : number ,
133+ builder : RangeSetBuilder < Decoration > ,
134+ ) {
135+ for ( let option of [ "|noembed" , "|embed" , "|fullwidth" ] ) {
136+ if ( text . includes ( option ) ) {
137+ const start = text . indexOf ( option ) + startOfLine ;
138+ const end = start + option . length ;
139+
140+ const deco = Decoration . replace ( { } ) ;
141+ builder . add ( start , end , deco ) ;
142+ }
143+ }
144+ }
124145 } ,
125146 {
126147 decorations : ( v ) => v . decorations ,
0 commit comments